View Source AntikytheraCore.AsyncJob.Queue (antikythera v0.5.1)

A queue-like data structure, replicated using RaftedValue, to store AntikytheraCore.AsyncJob structs.

Summary

Functions

Type-aware getter for abandoned_jobs.

Type-aware setter for abandoned_jobs.

Type-aware getter for brokers_to_notify.

Type-aware setter for brokers_to_notify.

Type-aware getter for brokers_waiting.

Type-aware setter for brokers_waiting.

Type-aware getter for index_runnable.

Type-aware setter for index_runnable.

Type-aware getter for index_running.

Type-aware setter for index_running.

Type-aware getter for index_waiting.

Type-aware setter for index_waiting.

Type-aware getter for jobs.

Type-aware setter for jobs.

Creates a new instance of AntikytheraCore.AsyncJob.Queue by using the given dict.

A variant of new/1 which returns t or raise if validation fails.

Updates an existing instance of AntikytheraCore.AsyncJob.Queue with the given dict. The values in the dict are validated by each field's valid?/1 function. Returns {:ok, valid_struct} or {:error, reason}.

A variant of update/2 which returns t or raise if validation fails. In other words, update/2 followed by Croma.Result.get!/1.

Checks if the given value belongs to t/0 or not.

Types

@type t() :: %AntikytheraCore.AsyncJob.Queue{
  abandoned_jobs:
    Croma.TypeGen.ListOf.AntikytheraCore.AsyncJob.Queue.IdJobPair.t(),
  brokers_to_notify: Croma.TypeGen.ListOf.Croma.Pid.t(),
  brokers_waiting: Croma.TypeGen.ListOf.Croma.Pid.t(),
  index_runnable: AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t(),
  index_running: AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t(),
  index_waiting: AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t(),
  jobs: AntikytheraCore.AsyncJob.Queue.JobsMap.t()
}

Functions

@spec abandoned_jobs(t()) ::
  Croma.TypeGen.ListOf.AntikytheraCore.AsyncJob.Queue.IdJobPair.t()

Type-aware getter for abandoned_jobs.

Link to this function

abandoned_jobs(s, field)

View Source
@spec abandoned_jobs(
  t(),
  Croma.TypeGen.ListOf.AntikytheraCore.AsyncJob.Queue.IdJobPair.t()
) :: t()

Type-aware setter for abandoned_jobs.

Link to this function

add_job(queue_name, job_id, job, start_time_millis, now_millis)

View Source
@spec add_job(
  atom(),
  Antikythera.AsyncJob.Id.t(),
  AntikytheraCore.AsyncJob.t(),
  pos_integer(),
  pos_integer()
) :: :ok | {:error, :full | :existing_id | {:rate_limit_reached, pos_integer()}}
Link to this function

brokers_to_notify(queue)

View Source
@spec brokers_to_notify(t()) :: Croma.TypeGen.ListOf.Croma.Pid.t()

Type-aware getter for brokers_to_notify.

Link to this function

brokers_to_notify(s, field)

View Source
@spec brokers_to_notify(t(), Croma.TypeGen.ListOf.Croma.Pid.t()) :: t()

Type-aware setter for brokers_to_notify.

@spec brokers_waiting(t()) :: Croma.TypeGen.ListOf.Croma.Pid.t()

Type-aware getter for brokers_waiting.

Link to this function

brokers_waiting(s, field)

View Source
@spec brokers_waiting(t(), Croma.TypeGen.ListOf.Croma.Pid.t()) :: t()

Type-aware setter for brokers_waiting.

Link to this function

cancel(queue_name, job_id)

View Source
@spec cancel(atom(), Antikythera.AsyncJob.Id.t()) ::
  :ok | {:error, :not_found | {:rate_limit_reached, pos_integer()}}
@spec index_runnable(t()) :: AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t()

Type-aware getter for index_runnable.

Link to this function

index_runnable(s, field)

View Source
@spec index_runnable(t(), AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t()) :: t()

Type-aware setter for index_runnable.

Type-aware getter for index_running.

@spec index_running(t(), AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t()) :: t()

Type-aware setter for index_running.

Type-aware getter for index_waiting.

@spec index_waiting(t(), AntikytheraCore.AsyncJob.Queue.SecondaryIndex.t()) :: t()

Type-aware setter for index_waiting.

Type-aware getter for jobs.

Type-aware setter for jobs.

Link to this function

make_rv_config(opts \\ [leader_hook_module: AntikytheraCore.AsyncJob.Queue.Hook, heartbeat_timeout: 1000, election_timeout: 5000, election_timeout_clock_drift_margin: 500])

View Source
@spec make_rv_config(Keyword.t()) :: RaftedValue.Config.t()
@spec new(term()) :: Croma.Result.t(t())

Creates a new instance of AntikytheraCore.AsyncJob.Queue by using the given dict.

Returns {:ok, valid_struct} or {:error, reason}.

The values in the dict are validated by each field's valid?/1 function. If the value was invalid, it will be passed to new/1 of the field

For missing fields, followings will be tried:

  • default/0 of each field type
  • new/1 of each field type, with empty map as input
@spec new!(term()) :: t()

A variant of new/1 which returns t or raise if validation fails.

In other words, new/1 followed by Croma.Result.get!/1.

Link to this function

remove_broker_from_waiting_list(queue_name)

View Source
@spec remove_broker_from_waiting_list(atom()) :: :ok
Link to this function

remove_locked_job(queue_name, job_key)

View Source
@spec remove_locked_job(atom(), AntikytheraCore.AsyncJob.Queue.JobKey.t()) :: :ok
Link to this function

start_jobs_and_get_metrics(pid)

View Source
@spec start_jobs_and_get_metrics(pid()) :: nil | tuple()
Link to this function

status(queue_name, job_id)

View Source
Link to this function

unlock_job_for_retry(queue_name, job_key)

View Source
@spec unlock_job_for_retry(atom(), AntikytheraCore.AsyncJob.Queue.JobKey.t()) :: :ok
@spec update(t(), Dict.t()) :: Croma.Result.t(t())

Updates an existing instance of AntikytheraCore.AsyncJob.Queue with the given dict. The values in the dict are validated by each field's valid?/1 function. Returns {:ok, valid_struct} or {:error, reason}.

@spec update!(t(), Dict.t()) :: t()

A variant of update/2 which returns t or raise if validation fails. In other words, update/2 followed by Croma.Result.get!/1.

@spec valid?(term()) :: boolean()

Checks if the given value belongs to t/0 or not.