From b3b06f462d32dc6190de4d54b62c439dcecaf03b Mon Sep 17 00:00:00 2001 From: Joseph Little Date: Mon, 1 Jul 2024 10:46:26 +0100 Subject: [PATCH] client config struct comments added --- httpclient/client.go | 55 +++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/httpclient/client.go b/httpclient/client.go index 520510d..6f7d71f 100644 --- a/httpclient/client.go +++ b/httpclient/client.go @@ -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.