Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/thediveo/enumflag"
"golang.org/x/time/rate"
"os"
"time"

"github.com/caarlos0/env/v6"
"github.com/elasticpath/epcc-cli/external/json"
Expand All @@ -20,6 +21,8 @@ import (

var rateLimit uint16

var requestTimeout float32

func init() {
cobra.OnInitialize(initConfig)

Expand Down Expand Up @@ -58,6 +61,7 @@ func init() {
RootCmd.PersistentFlags().StringSliceVarP(&httpclient.RawHeaders, "header", "H", []string{}, "Extra headers and values to include in the request when sending HTTP to a server. You may specify any number of extra headers.")
RootCmd.PersistentFlags().StringVarP(&profiles.ProfileName, "profile", "P", "default", "overrides the current EPCC_PROFILE var to run the command with the chosen profile.")
RootCmd.PersistentFlags().Uint16VarP(&rateLimit, "rate-limit", "", 10, "Request limit per second")
RootCmd.PersistentFlags().Float32VarP(&requestTimeout, "timeout", "", 10, "Request timeout in seconds (fractional values allowed)")

create.Flags().StringVar(&crud.OverrideUrlPath, "override-url-path", "", "Override the URL that will be used for the Request")
delete.Flags().StringVar(&crud.OverrideUrlPath, "override-url-path", "", "Override the URL that will be used for the Request")
Expand Down Expand Up @@ -109,6 +113,7 @@ Environment Variables
}
log.Debugf("Rate limit set to %d request per second ", rateLimit)
httpclient.Limit = rate.NewLimiter(rate.Limit(rateLimit), 1)
httpclient.HttpClient.Timeout = time.Duration(int64(requestTimeout*1000) * int64(time.Millisecond))

for _, runFunc := range persistentPreRunFuncs {
err := runFunc(cmd, args)
Expand Down
4 changes: 1 addition & 3 deletions external/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ var stats = struct {
totalRequests uint64
}{}

var HttpClient = &http.Client{
Timeout: time.Second * 10,
}
var HttpClient = &http.Client{}

func LogStats() {
statsLock.Lock()
Expand Down