Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StopOrContinue ¶
StopOrContinue can help controlling the behaviour of concurrent GET requests when using an errgroup and encountering an error. Depending on the NVD_CONTINUE_DOWNLOADING env variable, this function will return the passed error (when we want to stop pending requests) or just log the error (when we want the pending requests to continue being processed).
Types ¶
type Client ¶
type Client interface { Do(req *http.Request) (*http.Response, error) Get(url string) (*http.Response, error) }
Client is an interface used for making http requests
func WithRetries ¶
WithRetries will retry all given requests for the specified number of times
- if status is 200, returns
- if status is covered by the retry policy and hasn't been retried the total number of times, retry
- otherwise, fail the request
func WithThrottling ¶
WithThrottling creates a rate limitted client - all requests are throttled
func WithUserAgent ¶
WithUserAgent wrapps the given client in a way that it always makes requests with User Agent header
type Config ¶
type Config struct { UserAgent string // contains filtered or unexported fields }
Config is used to configure a client
func (*Config) AddFlags ¶
func (conf *Config) AddFlags()
AddFlags adds flags used to configure a client
type FailedRetries ¶
type FailedRetries int
FailedRetries is an error returned when all retries have been exhausted
func (FailedRetries) Error ¶
func (fr FailedRetries) Error() string
Error is a part of the error interface
type RetryPolicy ¶
RetryPolicy is a function which returns true if HTTP status should be retried
func (*RetryPolicy) Set ¶
func (rp *RetryPolicy) Set(s string) error
func (*RetryPolicy) String ¶
func (rp *RetryPolicy) String() string