Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type Config
- type Doer
- type ReConfiguration
- func (reConfiguration *ReConfiguration) Client() *http.Client
- func (reConfiguration *ReConfiguration) Do(request *http.Request) (*http.Response, error)
- func (reConfiguration *ReConfiguration) ReConfiguration(configurator configurator.Configurator) error
- func (reConfiguration *ReConfiguration) Use(middlewares ...middleware.Func)
Constants ¶
View Source
const ( TimeoutFieldName = "client.http.timeout" MaxIdleConnectionsFieldName = "client.http.maximum.idle.connections" MaxIdleConnectionsPerHostFieldName = "client.http.maximum.idle.host" MaxConnectionsPerHostFieldName = "client.http.maximum.connections" SecureVerifyFieldName = "client.http.secure_verify" TimeoutDefault = 30 * time.Second MaxIdleConnectionsDefault = uint16(100) MaxIdleConnectionsPerHostDefault = uint16(10) MaxConnectionsPerHostDefault = uint16(20) SecureVerifyDefault = false )
Variables ¶
View Source
var Component = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, re_configuration.Component, info.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewConfig, NewReConfigurationWithConfigurator, func(reConfiguration *ReConfiguration) Doer { return reConfiguration }, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.DurationVar(&config.Timeout, TimeoutFieldName, TimeoutDefault, "request timeout") flagSet.Uint16Var(&config.MaxIdleConnections, MaxIdleConnectionsFieldName, MaxIdleConnectionsDefault, "maximum total number of open connections") flagSet.Uint16Var(&config.MaxIdleConnectionsPerHost, MaxIdleConnectionsPerHostFieldName, MaxIdleConnectionsPerHostDefault, "maximum number of open connections per host") flagSet.Uint16Var(&config.MaxConnectionsPerHost, MaxConnectionsPerHostFieldName, MaxConnectionsPerHostDefault, "maximum number of connections per host") flagSet.BoolVar(&config.SecureVerify, SecureVerifyFieldName, SecureVerifyDefault, "if true, check the TLS certificate") }) }, Run: func(c container.Container) error { client, err := container.Get[*ReConfiguration](c) if err != nil { return err } logger, err := container.Get[logger.Logger](c) if err != nil { return err } appConfig, err := container.Get[*app.Config](c) if err != nil { return err } client.Use( middleware.RequestLogger(logger), middleware.RequestDuration(appConfig, logger), middleware.TotalRequestCount(appConfig, logger), ) reConfiguration, err := container.Get[configurator.ReConfiguration](c) if err != nil { return err } reConfiguration.Registration(client) logger.Info("http.client: registration in the reConfigurator") info, err := container.Get[info.Info](c) if err != nil { return err } config, err := container.Get[*Config](c) if err != nil { return err } info.Registration("http.client", config) return nil }, }
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithConfigurator ¶
func NewWithConfigurator(configurator configurator.Configurator, config *Config, informer logger.Informer) *Client
func (*Client) Use ¶
func (client *Client) Use(middlewares ...middleware.Func)
type Config ¶
type Config struct { Timeout time.Duration MaxIdleConnections uint16 MaxIdleConnectionsPerHost uint16 MaxConnectionsPerHost uint16 SecureVerify bool }
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
type ReConfiguration ¶
type ReConfiguration struct {
// contains filtered or unexported fields
}
func NewReConfiguration ¶
func NewReConfiguration(informer logger.Informer, config *Config) *ReConfiguration
func NewReConfigurationWithConfigurator ¶
func NewReConfigurationWithConfigurator(informer logger.Informer, config *Config, configurator configurator.Configurator) *ReConfiguration
func (*ReConfiguration) Client ¶
func (reConfiguration *ReConfiguration) Client() *http.Client
func (*ReConfiguration) ReConfiguration ¶
func (reConfiguration *ReConfiguration) ReConfiguration(configurator configurator.Configurator) error
func (*ReConfiguration) Use ¶
func (reConfiguration *ReConfiguration) Use(middlewares ...middleware.Func)
Click to show internal directories.
Click to hide internal directories.