internal

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMaxRetries     = errors.New("max retries reached")
	ErrContextIsNil   = errors.New("context must be non-nil")
	ErrKeyNotProvided = errors.New("api key not provided")
)

Functions

func NewLogger

func NewLogger(config api.EquinoxConfig, cache *cache.Cache, ratelimit *ratelimit.RateLimit) zerolog.Logger

Creates a new zerolog.Logger from an EquinoxConfig.

Types

type Client

type Client struct {
	IsCacheEnabled     bool
	IsRateLimitEnabled bool
	IsRetryEnabled     bool
	// contains filtered or unexported fields
}

func NewInternalClient

func NewInternalClient(config api.EquinoxConfig, h *http.Client, c *cache.Cache, r *ratelimit.RateLimit) (*Client, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, equinoxReq api.EquinoxRequest) (*http.Response, error)

Sends the request using the internal http.Client, retries if enabled.

func (*Client) Execute

func (c *Client) Execute(ctx context.Context, equinoxReq api.EquinoxRequest, target any) error

Executes a 'EquinoxRequest', checks cache and unmarshals the response into 'target'.

ctx accepts 'api.ExecuteOptions', 'api.Revalidate' for example can be used to revalidate the cache, forcing an update to it.

func (*Client) ExecuteBytes

func (c *Client) ExecuteBytes(ctx context.Context, equinoxReq api.EquinoxRequest) ([]byte, error)

Executes a 'EquinoxRequest', skips checking cache and returns []byte.

func (*Client) Logger

func (c *Client) Logger(id string) zerolog.Logger

Used to create/retrieve the zerolog.Logger for the specified endpoint method.

func (*Client) Request

func (c *Client) Request(ctx context.Context, logger zerolog.Logger, httpMethod string, urlComponents []string, methodID string, body any) (api.EquinoxRequest, error)

Creates a new 'EquinoxRequest' object for the 'Execute' and 'ExecuteBytes' methods.

Jump to

Keyboard shortcuts

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