Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set-up HTTP timeout when communicating with CrowdStrike Falcon API #144

Merged
merged 1 commit into from Oct 21, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}