mirror of
https://github.com/retailcrm/mg-transport-core.git
synced 2024-11-22 13:16:04 +03:00
removed HTTPClientConfigInterface because it breaks configuration unmarshaling
This commit is contained in:
parent
6057e3cb4f
commit
9bd8eca75a
@ -30,7 +30,7 @@ type ConfigInterface interface {
|
|||||||
GetDBConfig() DatabaseConfig
|
GetDBConfig() DatabaseConfig
|
||||||
GetAWSConfig() ConfigAWS
|
GetAWSConfig() ConfigAWS
|
||||||
GetTransportInfo() InfoInterface
|
GetTransportInfo() InfoInterface
|
||||||
GetHTTPClientConfig() HTTPClientConfigInterface
|
GetHTTPClientConfig() *HTTPClientConfig
|
||||||
GetUpdateInterval() int
|
GetUpdateInterval() int
|
||||||
IsDebug() bool
|
IsDebug() bool
|
||||||
}
|
}
|
||||||
@ -42,14 +42,6 @@ type InfoInterface interface {
|
|||||||
GetLogoPath() string
|
GetLogoPath() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPClientConfigInterface can be used to provide alternative way for configuring HTTP server
|
|
||||||
type HTTPClientConfigInterface interface {
|
|
||||||
GetTimeout() time.Duration
|
|
||||||
IsSSLVerificationEnabled() bool
|
|
||||||
GetMockAddress() string
|
|
||||||
GetMockedDomains() []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config struct
|
// Config struct
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Version string `yaml:"version"`
|
Version string `yaml:"version"`
|
||||||
@ -61,7 +53,7 @@ type Config struct {
|
|||||||
UpdateInterval int `yaml:"update_interval"`
|
UpdateInterval int `yaml:"update_interval"`
|
||||||
ConfigAWS ConfigAWS `yaml:"config_aws"`
|
ConfigAWS ConfigAWS `yaml:"config_aws"`
|
||||||
TransportInfo Info `yaml:"transport_info"`
|
TransportInfo Info `yaml:"transport_info"`
|
||||||
HTTPClientConfig HTTPClientConfigInterface `yaml:"http_client"`
|
HTTPClientConfig *HTTPClientConfig `yaml:"http_client"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info struct
|
// Info struct
|
||||||
@ -189,7 +181,7 @@ func (c Config) GetUpdateInterval() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetHTTPClientConfig returns http client config
|
// GetHTTPClientConfig returns http client config
|
||||||
func (c Config) GetHTTPClientConfig() HTTPClientConfigInterface {
|
func (c Config) GetHTTPClientConfig() *HTTPClientConfig {
|
||||||
return c.HTTPClientConfig
|
return c.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,15 +200,6 @@ func (t Info) GetLogoPath() string {
|
|||||||
return t.LogoPath
|
return t.LogoPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTimeout returns timeout for HTTP client (default is 30 seconds)
|
|
||||||
func (h *HTTPClientConfig) GetTimeout() time.Duration {
|
|
||||||
if h.Timeout <= 0 {
|
|
||||||
h.Timeout = 30 * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
return h.Timeout
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSSLVerificationEnabled returns SSL verification flag (default is true)
|
// IsSSLVerificationEnabled returns SSL verification flag (default is true)
|
||||||
func (h *HTTPClientConfig) IsSSLVerificationEnabled() bool {
|
func (h *HTTPClientConfig) IsSSLVerificationEnabled() bool {
|
||||||
if h.SSLVerification == nil {
|
if h.SSLVerification == nil {
|
||||||
@ -225,13 +208,3 @@ func (h *HTTPClientConfig) IsSSLVerificationEnabled() bool {
|
|||||||
|
|
||||||
return *h.SSLVerification
|
return *h.SSLVerification
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMockAddress returns mock address
|
|
||||||
func (h *HTTPClientConfig) GetMockAddress() string {
|
|
||||||
return h.MockAddress
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMockedDomains returns mocked domains list
|
|
||||||
func (h *HTTPClientConfig) GetMockedDomains() []string {
|
|
||||||
return h.MockedDomains
|
|
||||||
}
|
|
||||||
|
@ -41,6 +41,10 @@ log_level: 5
|
|||||||
debug: true
|
debug: true
|
||||||
update_interval: 24
|
update_interval: 24
|
||||||
|
|
||||||
|
http_client:
|
||||||
|
ssl_verification: false
|
||||||
|
timeout: 30
|
||||||
|
|
||||||
config_aws:
|
config_aws:
|
||||||
access_key_id: key
|
access_key_id: key
|
||||||
secret_access_key: secret
|
secret_access_key: secret
|
||||||
|
@ -122,18 +122,18 @@ func (b *HTTPClientBuilder) SetLogging(flag bool) *HTTPClientBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FromConfig fulfills mock configuration from HTTPClientConfig
|
// FromConfig fulfills mock configuration from HTTPClientConfig
|
||||||
func (b *HTTPClientBuilder) FromConfig(config HTTPClientConfigInterface) *HTTPClientBuilder {
|
func (b *HTTPClientBuilder) FromConfig(config *HTTPClientConfig) *HTTPClientBuilder {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.GetMockAddress() != "" {
|
if config.MockAddress != "" {
|
||||||
b.SetMockAddress(config.GetMockAddress())
|
b.SetMockAddress(config.MockAddress)
|
||||||
b.SetMockedDomains(config.GetMockedDomains())
|
b.SetMockedDomains(config.MockedDomains)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.GetTimeout() > 0 {
|
if config.Timeout > 0 {
|
||||||
b.SetTimeout(config.GetTimeout())
|
b.SetTimeout(config.Timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
b.SetSSLVerification(config.IsSSLVerificationEnabled())
|
b.SetSSLVerification(config.IsSSLVerificationEnabled())
|
||||||
|
@ -102,7 +102,7 @@ func (t *HTTPClientBuilderTest) Test_FromEngine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.builder.FromEngine(engine)
|
t.builder.FromEngine(engine)
|
||||||
assert.Equal(t.T(), engine.Config.GetHTTPClientConfig().GetMockAddress(), t.builder.mockAddress)
|
assert.Equal(t.T(), engine.Config.GetHTTPClientConfig().MockAddress, t.builder.mockAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *HTTPClientBuilderTest) Test_buildDialer() {
|
func (t *HTTPClientBuilderTest) Test_buildDialer() {
|
||||||
|
Loading…
Reference in New Issue
Block a user