diff --git a/command/command.go b/command/command.go index b9367814..e291429e 100644 --- a/command/command.go +++ b/command/command.go @@ -693,8 +693,8 @@ func buildUA(ver, rev string) string { } // NewMackerelClient returns Mackerel API client for mackerel-agent -func NewMackerelClient(apibase, apikey, ver, rev string, verbose bool, disableKeepAlive bool) (*mackerel.API, error) { - api, err := mackerel.NewAPI(apibase, apikey, verbose, disableKeepAlive) +func NewMackerelClient(apibase, apikey, ver, rev string, verbose bool, disableHttpKeepAlive bool) (*mackerel.API, error) { + api, err := mackerel.NewAPI(apibase, apikey, verbose, disableHttpKeepAlive) if err != nil { return nil, err } @@ -708,7 +708,7 @@ func NewMackerelClient(apibase, apikey, ver, rev string, verbose bool, disableKe // Prepare sets up API and registers the host data to the Mackerel server. // Use returned values to call Run(). func Prepare(conf *config.Config, ameta *AgentMeta) (*App, error) { - api, err := NewMackerelClient(conf.Apibase, conf.Apikey, ameta.Version, ameta.Revision, conf.Verbose, conf.DisableKeepAlive) + api, err := NewMackerelClient(conf.Apibase, conf.Apikey, ameta.Version, ameta.Revision, conf.Verbose, conf.DisableHttpKeepAlive) if err != nil { return nil, fmt.Errorf("failed to prepare an api: %s", err.Error()) } diff --git a/commands.go b/commands.go index 022187ba..069bea95 100644 --- a/commands.go +++ b/commands.go @@ -156,7 +156,7 @@ func doRetire(fs *flag.FlagSet, argv []string) error { return fmt.Errorf("hostID file is not found or empty") } - api, err := command.NewMackerelClient(conf.Apibase, conf.Apikey, version, gitcommit, conf.Verbose, conf.DisableKeepAlive) + api, err := command.NewMackerelClient(conf.Apibase, conf.Apikey, version, gitcommit, conf.Verbose, conf.DisableHttpKeepAlive) if err != nil { return fmt.Errorf("faild to create api client: %s", err) } diff --git a/config/config.go b/config/config.go index db77858a..d1190329 100644 --- a/config/config.go +++ b/config/config.go @@ -93,24 +93,24 @@ func (c *CloudPlatform) UnmarshalText(text []byte) error { // Config represents mackerel-agent's configuration file. type Config struct { - Apibase string - Apikey string - Root string - Pidfile string - Conffile string - Roles []string - Verbose bool - Silent bool - Diagnostic bool `toml:"diagnostic"` - DisableKeepAlive bool `toml:"disable_keep_alive"` - DisplayName string `toml:"display_name"` - HostStatus HostStatus `toml:"host_status" conf:"parent"` - Disks Disks `toml:"disks" conf:"parent"` - Filesystems Filesystems `toml:"filesystems" conf:"parent"` - Interfaces Interfaces `toml:"interfaces" conf:"parent"` - HTTPProxy string `toml:"http_proxy"` - HTTPSProxy string `toml:"https_proxy"` - CloudPlatform CloudPlatform `toml:"cloud_platform"` + Apibase string + Apikey string + Root string + Pidfile string + Conffile string + Roles []string + Verbose bool + Silent bool + Diagnostic bool `toml:"diagnostic"` + DisableHttpKeepAlive bool `toml:"disable_http_keep_alive"` + DisplayName string `toml:"display_name"` + HostStatus HostStatus `toml:"host_status" conf:"parent"` + Disks Disks `toml:"disks" conf:"parent"` + Filesystems Filesystems `toml:"filesystems" conf:"parent"` + Interfaces Interfaces `toml:"interfaces" conf:"parent"` + HTTPProxy string `toml:"http_proxy"` + HTTPSProxy string `toml:"https_proxy"` + CloudPlatform CloudPlatform `toml:"cloud_platform"` // This Plugin field is used to decode the toml file. After reading the // configuration from file, this field is set to nil. @@ -448,8 +448,8 @@ func LoadConfig(conffile string) (*Config, error) { if !config.Diagnostic { config.Diagnostic = DefaultConfig.Diagnostic } - if !config.DisableKeepAlive { - config.DisableKeepAlive = DefaultConfig.DisableKeepAlive + if !config.DisableHttpKeepAlive { + config.DisableHttpKeepAlive = DefaultConfig.DisableHttpKeepAlive } return config, err diff --git a/config/config_test.go b/config/config_test.go index 208c39e9..ae0fe6ef 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -100,7 +100,7 @@ func TestLoadConfig(t *testing.T) { t.Error("should be false (default value should be used)") } - if config.DisableKeepAlive != false { + if config.DisableHttpKeepAlive != false { t.Error("should be false (default value should be used)") } } diff --git a/mackerel/api.go b/mackerel/api.go index fd06b1b0..bb661c3a 100644 --- a/mackerel/api.go +++ b/mackerel/api.go @@ -57,14 +57,14 @@ func infoError(msg string) *InfoError { } // NewAPI creates a new instance of API. -func NewAPI(rawurl string, apiKey string, verbose bool, disableKeepAlive bool) (*API, error) { +func NewAPI(rawurl string, apiKey string, verbose bool, disableHttpKeepAlive bool) (*API, error) { c, err := mkr.NewClientWithOptions(apiKey, rawurl, verbose) if err != nil { return nil, err } c.PrioritizedLogger = logger t := http.DefaultTransport.(*http.Transport).Clone() - t.DisableKeepAlives = disableKeepAlive + t.DisableKeepAlives = disableHttpKeepAlive c.HTTPClient.Transport = t return &API{Client: c}, nil