Skip to content

Commit

Permalink
Changed disable_keep_alive to disable_http_keep_alive
Browse files Browse the repository at this point in the history
  • Loading branch information
appare45 committed Dec 20, 2024
1 parent 7022f7c commit 05dcf6b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
40 changes: 20 additions & 20 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
}
Expand Down
4 changes: 2 additions & 2 deletions mackerel/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05dcf6b

Please sign in to comment.