Skip to content

Commit

Permalink
Merge pull request #29 from Somefive/feat/add-min-request-timeout-arg
Browse files Browse the repository at this point in the history
Feat: add min-request-timeout args
  • Loading branch information
Somefive authored Oct 24, 2022
2 parents 42496db + bb87806 commit c431248
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/util/apiserver/options/server_run_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@ import (

// ServerRunOptions is the extension option for configuring the APIServer
type ServerRunOptions struct {
RequestTimeout time.Duration
RequestTimeout time.Duration
MinRequestTimeout int
}

func NewServerRunOptions() *ServerRunOptions {
defaults := server.NewConfig(serializer.CodecFactory{})
return &ServerRunOptions{
RequestTimeout: defaults.RequestTimeout,
RequestTimeout: defaults.RequestTimeout,
MinRequestTimeout: defaults.MinRequestTimeout,
}
}

// ApplyTo set the params in server.RecommendConfig
func (s *ServerRunOptions) ApplyTo(c *server.Config) error {
c.RequestTimeout = s.RequestTimeout
c.MinRequestTimeout = s.MinRequestTimeout
return nil
}

Expand All @@ -49,6 +52,11 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
"An optional field indicating the duration a handler must keep a request open before timing "+
"it out. This is the default request timeout for requests but may be overridden by flags such as "+
"--min-request-timeout for specific types of requests.")
fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", s.MinRequestTimeout, ""+
"An optional field indicating the minimum number of seconds a handler must keep "+
"a request open before timing it out. Currently only honored by the watch request "+
"handler, which picks a randomized value above this number as the connection timeout, "+
"to spread out load.")
}

var defaultServerRunOptions = NewServerRunOptions()
Expand Down

0 comments on commit c431248

Please sign in to comment.