http

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const ChromaGoClientUserAgent = "chroma-go-client/0.1.x"
View Source
const MaxResponseBodySize = 200 * 1024 * 1024

MaxResponseBodySize is the maximum allowed response body size (200 MB).

Variables

This section is empty.

Functions

func ReadLimitedBody added in v0.3.3

func ReadLimitedBody(r io.Reader) ([]byte, error)

ReadLimitedBody reads up to MaxResponseBodySize bytes from r. Returns an error if the response exceeds the limit.

func ReadRespBody

func ReadRespBody(resp io.Reader) string

Types

type ChromaError

type ChromaError struct {
	ErrorID   string `json:"error"`
	ErrorCode int    `json:"error_code"`
	Message   string `json:"message"`
}

ChromaError represents an error returned by the Chroma API. It contains the ID of the error, the error message and the status code from the HTTP call. Example:

{
 "error": "NotFoundError",
 "message": "Tenant default_tenant2 not found"
}

func ChromaErrorFromHTTPResponse

func ChromaErrorFromHTTPResponse(resp *http.Response, err error) *ChromaError

func (*ChromaError) Error

func (e *ChromaError) Error() string

type Option

type Option func(*SimpleRetryStrategy) error

func WithExponentialBackOff

func WithExponentialBackOff() Option

func WithFixedDelay

func WithFixedDelay(delay time.Duration) Option

func WithMaxRetries

func WithMaxRetries(retries int) Option

func WithRetryableStatusCodes

func WithRetryableStatusCodes(statusCodes ...int) Option

type RetryStrategy

type RetryStrategy interface {
	DoWithRetry(client *http.Client, req *http.Request) (*http.Response, error)
}

type SimpleRetryStrategy

type SimpleRetryStrategy struct {
	MaxRetries           int
	FixedDelay           time.Duration
	ExponentialBackOff   bool
	RetryableStatusCodes []int
}

func NewSimpleRetryStrategy

func NewSimpleRetryStrategy(opts ...Option) (*SimpleRetryStrategy, error)

func (*SimpleRetryStrategy) DoWithRetry

func (r *SimpleRetryStrategy) DoWithRetry(client *http.Client, req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL