package
0.0.0-20250311023717-5c21e974eed8
Repository: https://github.com/thrasher-corp/gocryptotrader.git
Documentation: pkg.go.dev

# README

GoCryptoTrader package Request

Build Status Software License GoDoc Coverage Status Go Report Card

This request package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on our GoCryptoTrader Kanban board.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for request

  • This package services the exchanges package with request handling.
    • Throttling of requests for an individual exchange

Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

# Functions

DefaultBackoff is a default strategy for backoff after a retryable request failure.
DefaultRetryPolicy determines whether the request should be retried, implemented with a default strategy.
GetRateLimiterWithWeight couples a rate limiter with a weight count into an accepted defined rate limiter with weight struct.
IsVerbose checks main verbosity first then checks context verbose values for specific request verbosity.
LinearBackoff applies a backoff increasing by a base amount with each retry capped at a maximum duration.
New returns a new Requester.
NewBasicRateLimit returns an object that implements the limiter interface for basic rate limit.
NewRateLimit creates a new RateLimit based of time interval and how many actions allowed and breaks it down to an actions-per-second basis -- Burst rate is kept as one as this is not supported for out-bound requests.
NewRateLimitWithWeight creates a new RateLimit based of time interval and how many actions allowed.
NewWeightedRateLimitByDuration creates a new RateLimit based of time interval.
RateLimit is a function that will rate limit a request based on the rate limiter provided.
RetryAfter parses the Retry-After header in the response to determine the minimum duration needed to wait before retrying.
SetupGlobalReporter sets a reporter interface to be used for all exchange requests.
WithBackoff configures the backoff strategy for a Requester.
WithLimiter configures the rate limiter for a Requester.
WithReporter configures the reporter for a Requester.
WithRetryPolicy configures the retry policy for a Requester.
WithVerbose adds verbosity to a request context so that specific requests can have distinct verbosity without impacting all requests.

# Constants

Const here define individual functionality sub types for rate limiting.
AuthenticatedRequest denotes a request using API credentials.
Const vars for rate limiter.
Const vars for rate limiter.
Const here define individual functionality sub types for rate limiting.
UnauthenticatedRequest denotes a request with no credentials.
Const here define individual functionality sub types for rate limiting.
UnsetRequest is an unset request authentication level.

# Variables

ErrAuthRequestFailed is a wrapping error to denote that it's an auth request that failed.
ErrBadStatus is a wrapping error to denote that the HTTP status code was unsuccessful.
Defines rate limiting errors.
Defines rate limiting errors.
ErrRequestSystemIsNil defines and error if the request system has not been set up yet.
Vars for rate limiter.

# Structs

Item is a temp item for requests.
RateLimiterWithWeight is a rate limiter coupled with a weight count which refers to the number or weighting of the request.
Requester struct for the request client.

# Interfaces

Reporter interface groups observability functionality over HTTP request latency.

# Type aliases

AuthType helps distinguish the purpose of a HTTP request.
Backoff determines how long to wait between request attempts.
EndpointLimit defines individual endpoint rate limits that are set when New is called.
Generate defines a closure for functionality outside the requester to generate a new *http.Request on every attempt.
RateLimitDefinitions is a map of endpoint limits to rate limiters.
RequesterOption is a function option that can be applied to configure a Requester when creating it.
Reservations is a slice of rate reservations.
RetryPolicy determines whether the request should be retried.
Weight defines the number of reservations to be used.