Documentation
¶
Index ¶
- Constants
- func CloneNoRedirects(source *http.Client, timeout time.Duration) *http.Client
- func CompleteJSONSSE[T any](ctx context.Context, config JSONSSEConfig, wireRequest any, operation string, ...) (T, error)
- func DecodeBoundedJSON(reader io.Reader, maximum int64, target any) (bool, error)
- func FormatAPIError(detail APIError) string
- func FormatErrorMessage(prefix string, maximum int64, format string, arguments ...any) string
- func IsContextLimitAPIError(detail APIError) bool
- func IsObserverError(err error) bool
- func IsPartialResponseError(err error) bool
- func IsRetryableAPIError(detail APIError) bool
- func IsRetryableOperation(err error) bool
- func MarshalBoundedJSON(value any, maximum int64) ([]byte, bool, error)
- func NewJSONSSERequest(ctx context.Context, endpoint string, body []byte) (*http.Request, error)
- func NewObserverError(operation string, cause error) error
- func NewPartialResponseError(cause error) error
- func ParseRetryAfter(value string, now time.Time) time.Duration
- func ReadBounded(reader io.Reader, maximum int64) ([]byte, bool, error)
- func ReadBoundedText(reader io.Reader, maximum int64) (string, bool, error)
- func ReadHTTPStatusError(response *http.Response, maximum int64) error
- func ReadSSE(reader io.Reader, maximum int64, handle func([]byte) (bool, error)) (bool, error)
- func RetryDelay(failedAttempts int, base, maximum time.Duration) time.Duration
- func RetryDelayWithHint(failedAttempts int, base, maximum, hint time.Duration) time.Duration
- func RetryableHTTPStatus(status int) bool
- func RetryableNetworkError(err error) bool
- func TruncateUTF8(text string, maximum int) string
- type APIError
- type APIErrorCode
- type APIErrorConfig
- func (config APIErrorConfig) Do(ctx context.Context, client *http.Client, request *http.Request, ...) (*http.Response, error)
- func (config APIErrorConfig) Errorf(format string, arguments ...any) error
- func (config APIErrorConfig) RetryableWrapf(cause error, format string, arguments ...any) error
- func (config APIErrorConfig) Wrapf(cause error, format string, arguments ...any) error
- type APIResponseError
- type DeliveryTracker
- type GenerationLimits
- type JSONSSEConfig
- type ObserverError
- type PartialResponseError
- type RetryPolicy
- type TransportErrorDisposition
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func CloneNoRedirects ¶
func CompleteJSONSSE ¶
func DecodeBoundedJSON ¶
func FormatAPIError ¶
func FormatErrorMessage ¶
func IsContextLimitAPIError ¶
func IsObserverError ¶
func IsPartialResponseError ¶
func IsRetryableAPIError ¶
func IsRetryableOperation ¶
func NewJSONSSERequest ¶
func NewObserverError ¶
func NewPartialResponseError ¶
func RetryDelayWithHint ¶
func RetryableHTTPStatus ¶
func RetryableNetworkError ¶
func TruncateUTF8 ¶
Types ¶
type APIError ¶
type APIError struct {
Type string `json:"type"`
Code APIErrorCode `json:"code"`
Message string `json:"message"`
Metadata json.RawMessage `json:"metadata"`
}
type APIErrorCode ¶
type APIErrorCode string
func (*APIErrorCode) UnmarshalJSON ¶
func (code *APIErrorCode) UnmarshalJSON(data []byte) error
type APIErrorConfig ¶
type APIErrorConfig struct {
Prefix string
Maximum int64
ParseRetryAfter func(http.Header, time.Time) time.Duration
FormatDetail func(APIError) string
}
func (APIErrorConfig) Errorf ¶
func (config APIErrorConfig) Errorf(format string, arguments ...any) error
func (APIErrorConfig) RetryableWrapf ¶
func (config APIErrorConfig) RetryableWrapf(cause error, format string, arguments ...any) error
type APIResponseError ¶
type APIResponseError struct {
// contains filtered or unexported fields
}
func (*APIResponseError) Detail ¶
func (err *APIResponseError) Detail() APIError
func (*APIResponseError) Error ¶
func (err *APIResponseError) Error() string
func (*APIResponseError) RetryAfter ¶
func (err *APIResponseError) RetryAfter() time.Duration
func (*APIResponseError) StatusCode ¶
func (err *APIResponseError) StatusCode() int
func (*APIResponseError) Unwrap ¶
func (err *APIResponseError) Unwrap() error
type DeliveryTracker ¶
type DeliveryTracker struct {
// contains filtered or unexported fields
}
func (*DeliveryTracker) Deliver ¶
func (tracker *DeliveryTracker) Deliver(operation string, deliver func() error) error
func (*DeliveryTracker) Observed ¶
func (tracker *DeliveryTracker) Observed() bool
func (*DeliveryTracker) WrapPartial ¶
func (tracker *DeliveryTracker) WrapPartial(err error) error
type GenerationLimits ¶
func (GenerationLimits) WithDefaults ¶
func (limits GenerationLimits) WithDefaults() GenerationLimits
type JSONSSEConfig ¶
type ObserverError ¶
type ObserverError struct {
// contains filtered or unexported fields
}
func (*ObserverError) Error ¶
func (err *ObserverError) Error() string
func (*ObserverError) Unwrap ¶
func (err *ObserverError) Unwrap() error
type PartialResponseError ¶
type PartialResponseError struct {
// contains filtered or unexported fields
}
func (*PartialResponseError) Error ¶
func (err *PartialResponseError) Error() string
func (*PartialResponseError) Unwrap ¶
func (err *PartialResponseError) Unwrap() error
type RetryPolicy ¶
type TransportErrorDisposition ¶
func ClassifyTransportError ¶
func ClassifyTransportError(ctx context.Context, err error) TransportErrorDisposition
Click to show internal directories.
Click to hide internal directories.