Documentation ¶
Index ¶
- func NewBasicRetrier(max int, delayf func(int) time.Duration) *retrier
- func NewStatusCodeRetrier(max int, delayf func(int) time.Duration, retryCodes []int) *retrier
- type Client
- func (c *Client) Delete(ctx context.Context, endpoint string, body any, marshaler Marshaler, ...) (res *http.Response, err error)
- func (c *Client) Do(ctx context.Context, method string, endpoint string, body any, ...) (res *http.Response, err error)
- func (c *Client) Get(ctx context.Context, endpoint string, body any, marshaler Marshaler, ...) (res *http.Response, err error)
- func (c *Client) Patch(ctx context.Context, endpoint string, body any, marshaler Marshaler, ...) (res *http.Response, err error)
- func (c *Client) Post(ctx context.Context, endpoint string, body any, marshaler Marshaler, ...) (res *http.Response, err error)
- func (c *Client) Put(ctx context.Context, endpoint string, body any, marshaler Marshaler, ...) (res *http.Response, err error)
- type Configuration
- type HttpClient
- type Marshaler
- type MemPool
- type MemoryPool
- type Option
- func UseHighLevelMiddleware(mdw func(context.Context, *Request)) Option
- func UseHttpClient(client HttpClient) Option
- func UseHttpClientConstructor(constr func() HttpClient) Option
- func UseLowLevelMiddleware(mdw func(context.Context, *Request)) Option
- func UseMemoryPool(pool MemoryPool) Option
- func UseRetrier(retr Retrier) Option
- type Request
- func (r *Request) AddHeader(k, v string)
- func (r *Request) Error(err error)
- func (r *Request) Errors() []error
- func (r *Request) GetData() []byte
- func (r *Request) GetEndpoint() []byte
- func (r *Request) GetHeader(k string) (v string, ok bool)
- func (r *Request) GetMethod() string
- func (r *Request) GetQueryParam(k string) (v []string, ok bool)
- func (r *Request) GetResponse() *http.Response
- func (r *Request) Next()
- func (r *Request) RemoveHeader(k string)
- type Retrier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBasicRetrier ¶
NewBasicRetrier creates a retrier that retries requests up to an upper limit and waits for some duration between retries defined by the delay function. The basic retrier will only retry when the error is not nil.
func NewStatusCodeRetrier ¶
NewStatusCodeRetrier creates a retrier that retries requests up to an upper limit and waits for some duration between retries defined by the delay function. The basic retrier will only retry when the error is not nil.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an http.Client with additional functionality.
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration is a collection of options that apply to the client.
type HttpClient ¶
HttpClient defines features of an internal http clients that is used to execute http requests.
type Marshaler ¶
Marshaler defines how to convert an object into a byte array and its content type for making HTTP requests.
func NewFormMarshaler ¶
func NewFormMarshaler() Marshaler
NewXMLMarshaler creates a marshaler for application/x-www-form-urlencoded content type.
func NewJSONMarshaler ¶
func NewJSONMarshaler() Marshaler
NewJSONMarshaler creates a marshaler for application/json content type.
func NewXMLMarshaler ¶
func NewXMLMarshaler() Marshaler
NewXMLMarshaler creates a marshaler for application/xml content type.
type MemPool ¶
type MemPool struct {
// contains filtered or unexported fields
}
MemPool manages pooling memory allocations for reusing dyanmic memory.
func NewDefaultMemPool ¶
func NewDefaultMemPool() *MemPool
NewDefaultMemPool creates a memory pool with default page and pool size.
func NewMemPool ¶
NewMemPool creates a memory pool with a channel that provides byte arrays with the configured page size. The pool's channel has an upper limit of pool size.
type MemoryPool ¶
MemoryPool defines a pool that can be used to acquire memory and release memory as byte arrays.
type Option ¶
type Option interface {
Configure(c *Configuration)
}
Option defines objects that can change a Configuration.
func UseHighLevelMiddleware ¶
UseHighLevelMiddleware creates an option for adding a high level middleware that is executed before the endpoint url and request data are processed.
func UseHttpClient ¶
func UseHttpClient(client HttpClient) Option
UseHttpClient creates an option for setting the internal http client.
func UseHttpClientConstructor ¶
func UseHttpClientConstructor(constr func() HttpClient) Option
UseHttpClientConstructor creates an option for setting the constructor to create a new http client for each request.
func UseLowLevelMiddleware ¶
UseLowLevelMiddleware creates an option for adding a low level middleware that is executed before the headers are added and the request is executed.
func UseMemoryPool ¶
func UseMemoryPool(pool MemoryPool) Option
UseMemoryPool creates an option for setting the client's memory pool.
func UseRetrier ¶
UseRetrier creates an option for adding a retrier that retries the request until it succeeds.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request stores details about the request
func (*Request) GetEndpoint ¶
func (*Request) GetResponse ¶
func (*Request) Next ¶
func (r *Request) Next()
Next executes the next function on the function middleware on the request. If there are no more functions to call, it does nothing.