Shipstation v0.3.5 Shipstation.RequestLimit

This module is designed to record and handle the backpressure obligations the API client has against the API.

When a request is made, the response headers contain information about how many requests are allowed to be done within a given timeframe. This information is then stored in our Agent and used to determine if we should wait or not. Should the API Client go over the limit, the client will backoff, blocking the request until the elapsed time has been reached.

Summary

Functions

Wait a specified amount of time, so that the API has room to breathe

This function lets us set the rate information we’re getting back from the API

This function allows us to anticipate whether the API will reject our request

Return the current state

Functions

backoff()
backoff() :: any

Wait a specified amount of time, so that the API has room to breathe

calculate_backoff_period(future_time)
calculate_backoff_period(future_time :: %DateTime{calendar: term, day: term, hour: term, microsecond: term, minute: term, month: term, second: term, std_offset: term, time_zone: term, utc_offset: term, year: term, zone_abbr: term}) :: non_neg_integer
set_api_rate(arg)
set_api_rate({atom, HTTPoison.Response.t}) :: any

This function lets us set the rate information we’re getting back from the API

should_request?()
should_request?() :: boolean

This function allows us to anticipate whether the API will reject our request

start_link()
state()
state() :: {integer, integer, %DateTime{calendar: term, day: term, hour: term, microsecond: term, minute: term, month: term, second: term, std_offset: term, time_zone: term, utc_offset: term, year: term, zone_abbr: term}}

Return the current state