Documentation
¶
Overview ¶
Binds a wire protocol to an endpoint, a credential and an HTTP retry policy
Index ¶
Constants ¶
const UserAgent = "icebath"
Sent when neither the protocol nor the provider names a user agent
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attempt ¶
type Attempt struct {
URL string
Started time.Time
Duration time.Duration
Status int
// Transport or decoded wire failure, nil on a 2xx
Err error
// Pause before the next attempt, zero when this one was the last
Wait time.Duration
// Pause the endpoint asked for through Retry-After
RetryAfter time.Duration
RequestID string
RateLimit RateLimit
}
One HTTP attempt of a call with what came back and how long the provider will wait before the next
type Directive ¶
type Directive struct {
Header http.Header `json:"header,omitempty"`
Extra map[string]json.RawMessage `json:"extra,omitempty"`
}
Headers and body fields sent with a turn that asks for one directive
type Observer ¶
type Observer interface {
Observe(Attempt)
}
Receives every attempt a provider makes
type Provider ¶
type Provider struct {
Name string
Protocol protocol.Protocol
BaseURL string
Auth Auth
// Static headers every request carries after the protocol headers
Header http.Header
// Static query parameters every request carries
Query url.Values
// Request fields merged into every turn beneath the fields the request itself carries
Extra map[string]json.RawMessage
// Headers and body fields laid over every turn, how the endpoint hears what the profile asks of it
Directives []Directive
// Receives every attempt with its status, headers and backoff
Observer Observer
}
Protocol plus everything the protocol leaves to the endpoint
type RateLimit ¶
type RateLimit struct {
Requests int
RequestsRemaining int
Tokens int
TokensRemaining int
InputTokens int
InputRemaining int
OutputTokens int
OutputRemaining int
Reset time.Duration
}
What the endpoint reported about its quota on one response, zero where it said nothing
func ParseRateLimit ¶
Reads the rate limit headers of every supported vendor into one view