Tornex.Query (Tornex v0.3.0)
View SourceThe query struct containing API request data.
The Tornex.Query
struct is utilized by Tornex.API.get/1
and Tornex.Scheduler.Bucket.enqueue/1
to make API calls. Tornex.Query
stores the required information to perform the API call.
Tip
It is recommended to use Tornex.SpecQuery
for APIv2 requests as it uses the OpenAPI specification to generate types and to parse and validate API responses. However, APIv2 does not currently support all of the selections that APIv1 supports, so you may have to remain on v1 for the immediate future.
Summary
Functions
Determines the priority of a Tornex.Query
by the nice
value as a priority "bucket" atom.
Types
@type t() :: %Tornex.Query{ from: integer() | nil, key: String.t(), key_owner: integer(), limit: integer() | nil, nice: integer(), origin: GenServer.from() | nil, params: Keyword | nil, resource: String.t(), resource_id: integer() | String.t(), selections: [String.t()] | nil, sort: :asc | :desc | nil, timestamp: integer() | nil, to: integer() | nil }
Functions
@spec query_priority(query :: t() | Tornex.SpecQuery.t()) :: :user_request | :high_priority | :generic_request
Determines the priority of a Tornex.Query
by the nice
value as a priority "bucket" atom.
The nice value of a query is based on the Linux niceness value between -20 and 19. A niceness of -20 is the highest priority request and 19 is the lowest priority. For more information on the scheduling of requests against Tornex.Query
, see Tornex.Scheduler.Bucket
.
There are three priority buckets:
- generic requests (nice > 0) => Requests that are intended to be made with as much latency as needed
- high priority requests (-10 < nice <= 0) => Requests where latency matters
- user requests (nice <= -10) => Requests that should be performed immediately, typically initiated by a user action