Skip to content

Commit

Permalink
client config struct comments added
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeker12 committed Jul 1, 2024
1 parent fb43927 commit b3b06f4
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,49 @@ type Client struct {

// Options/Variables for Client
type ClientConfig struct {
Integration APIIntegration
HideSensitiveData bool `json:"hide_sensitive_data"`
CustomCookies []*http.Cookie
MaxRetryAttempts int `json:"max_retry_attempts"`
MaxConcurrentRequests int `json:"max_concurrent_requests"`
EnableDynamicRateLimiting bool `json:"enable_dynamic_rate_limiting"`
CustomTimeout time.Duration
TokenRefreshBufferPeriod time.Duration
TotalRetryDuration time.Duration
FollowRedirects bool `json:"follow_redirects"`
MaxRedirects int `json:"max_redirects"`
// Interface which implements the APIIntegration patterns. Integration handles all server/endpoint specific configuration, auth and vars.
Integration APIIntegration

// HideSenitiveData controls if sensitive data will be visible in logs. Debug option which should be True in production use.
HideSensitiveData bool `json:"hide_sensitive_data"`

// CustomCookies allows implementation of persistent, session wide cookies.
CustomCookies []*http.Cookie

// MaxRetry Attempts limits the amount of retries the client will perform on requests which are deemd retriable.
MaxRetryAttempts int `json:"max_retry_attempts"`

// MaxConcurrentRequests limits the amount of Semaphore tokens available to the client and therefor limits concurrent requests.
MaxConcurrentRequests int `json:"max_concurrent_requests"`

// EnableDynamicRateLimiting // TODO because I don't know.
EnableDynamicRateLimiting bool `json:"enable_dynamic_rate_limiting"`

// CustomTimeout // TODO also because I don't know.
CustomTimeout time.Duration

// TokenRefreshBufferPeriod is the duration of time before the token expires in which it's deemed
// more sensible to replace the token rather then carry on using it.
TokenRefreshBufferPeriod time.Duration

// TotalRetryDuration // TODO maybe this should be called context?
TotalRetryDuration time.Duration

// FollowRedirects allows the client to follow redirections when they're returned from a request.
FollowRedirects bool `json:"follow_redirects"`

// MaxRedirects is the maximum amount of redirects the client will follow before throwing an error.
MaxRedirects int `json:"max_redirects"`

// EnableConcurrencyManagement when false bypasses any concurrency management to allow for a simpler request flow.
EnableConcurrencyManagement bool `json:"enable_concurrency_management"`
MandatoryRequestDelay time.Duration
RetryEligiableRequests bool `json:"retry_eligiable_requests"`

// MandatoryRequestDelay is a short, usually sub 0.5 second, delay after every request as to not overwhelm an endpoint.
// Can be set to nothing if you want to be lightning fast!
MandatoryRequestDelay time.Duration

// RetryEligiableRequests when false bypasses any retry logic for a simpler request flow.
RetryEligiableRequests bool `json:"retry_eligiable_requests"`
}

// BuildClient creates a new HTTP client with the provided configuration.
Expand Down

0 comments on commit b3b06f4

Please sign in to comment.