Tornex.Query (Tornex v0.1.1)

View Source

The query struct containing API request data.

The Tornex.Query struct is utilized by Tornex.API.torn_get/1 and Tornex.Scheduler.Bucket.enqueue/1 to make API calls. The struct stores the required information to perform the API call.

Summary

Functions

Determines the priority of a Tornex.Query by the nice value as a priority "bucket" atom.

Types

t()

@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

query_priority(query)

@spec query_priority(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