Skip to content

Commit

Permalink
Set-up HTTP timeout when communicating with CrowdStrike Falcon API
Browse files Browse the repository at this point in the history
HttpTimeOutOverride allows users to override default HTTP Time-out (5 minutes).
This timeout should rarely be hit. The time-out protects user-application should
an unlikely event of CrowdStrike outage occur. Users that need to have more
control over HTTP time-outs are advised to use context.Context argument to API
calls instead of this variable.
  • Loading branch information
isimluk committed Oct 21, 2021
1 parent d18d4c5 commit a6bae3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions falcon/api_client.go
Expand Up @@ -28,6 +28,7 @@ func NewClient(ac *ApiConfig) (*client.CrowdStrikeAPISpecification, error) {
}
}
authenticatedClient := config.Client(ac.Context)
authenticatedClient.Timeout = ac.HttpTimeout()
authenticatedClient.Transport = &roundTripper{
T: authenticatedClient.Transport,
}
Expand Down
11 changes: 11 additions & 0 deletions falcon/api_config.go
Expand Up @@ -2,6 +2,7 @@ package falcon

import (
"context"
"time"

"github.com/crowdstrike/gofalcon/falcon/client"
)
Expand All @@ -22,6 +23,9 @@ type ApiConfig struct {
HostOverride string
// BasePathOverride allows to override default base path (default: /)
BasePathOverride string
// HttpTimeOutOverride allows users to override default HTTP Time-out (5 minutes). This timeout should rarely be hit. The time-out protects user-application should an unlikely event of CrowdStrike outage occur. Users that need to have more control over HTTP time-outs are advised to use context.Context argument to API calls instead of this variable.
HttpTimeOutOverride *time.Duration

// Debug forces print out of all http traffic going through the API Runtime
Debug bool
}
Expand All @@ -41,3 +45,10 @@ func (ac *ApiConfig) BasePath() string {
}
return ac.BasePathOverride
}

func (ac *ApiConfig) HttpTimeout() time.Duration {
if ac.HttpTimeOutOverride == nil {
return 5 * time.Minute
}
return *ac.HttpTimeOutOverride
}

0 comments on commit a6bae3a

Please sign in to comment.