queuetopia v0.6.3 Queuetopia.Jobs View Source

Link to this section Summary

Functions

Creates a job, specifying the performer, the Queuetopia (scope), and the user params, including options.

Returns true if a job is done. Otherwise, returns false.

Fetches a specific job. Acquires the lock on the queue and returns the job if it actually and reached it schedule time. In case of error, returns a tuple error.

Get the next available pending job of a given queue by scope a.k.a by Queuetopia. If the queue is empty or the next pendign job is scheduled for later, returns nil.

List the available pending queues by scope a.k.a by Queuetopia.

Performs the job. Let the performer do its job.

Persist in DB the result of job execution. Attempts fields are filled. In case of success, set the done_at field. Otherwise, save the error, prepare the job for a next retry, resetting the scheduled_at with the backoff calculation.

Returns true if a job scheduled date is reached and the job is not done yet. Otherwise, returns false.

Returns true if a job scheduled date is reached. Otherwise, returns false.

Link to this section Functions

Link to this function

create_job(repo, performer, scope, queue, action, params, opts \\ [])

View Source

Specs

create_job(module(), binary(), binary(), binary(), binary(), map(), [
  Queuetopia.Jobs.Job.option()
]) :: {:error, Ecto.Changeset.t()} | {:ok, Queuetopia.Jobs.Job.t()}

Creates a job, specifying the performer, the Queuetopia (scope), and the user params, including options.

Specs

Returns true if a job is done. Otherwise, returns false.

Specs

fetch_job(module(), Queuetopia.Jobs.Job.t()) :: {:error, any()} | {:ok, any()}

Fetches a specific job. Acquires the lock on the queue and returns the job if it actually and reached it schedule time. In case of error, returns a tuple error.

Link to this function

get_next_pending_job(repo, scope, queue)

View Source

Specs

get_next_pending_job(module(), binary(), binary()) ::
  Queuetopia.Jobs.Job.t() | nil

Get the next available pending job of a given queue by scope a.k.a by Queuetopia. If the queue is empty or the next pendign job is scheduled for later, returns nil.

Link to this function

list_available_pending_queues(repo, scope)

View Source

Specs

list_available_pending_queues(module(), binary()) :: [binary()]

List the available pending queues by scope a.k.a by Queuetopia.

Specs

perform(Queuetopia.Jobs.Job.t()) :: :ok | {:ok, any()} | {:error, binary()}

Performs the job. Let the performer do its job.

Link to this function

persist_result(repo, job, arg3)

View Source

Specs

persist_result(
  module(),
  Queuetopia.Jobs.Job.t(),
  {:error, any()} | :ok | {:ok, any()}
) :: Queuetopia.Jobs.Job.t()

Persist in DB the result of job execution. Attempts fields are filled. In case of success, set the done_at field. Otherwise, save the error, prepare the job for a next retry, resetting the scheduled_at with the backoff calculation.

Specs

processable_now?(Queuetopia.Jobs.Job.t()) :: boolean()

Returns true if a job scheduled date is reached and the job is not done yet. Otherwise, returns false.

Specs

scheduled_for_now?(Queuetopia.Jobs.Job.t()) :: boolean()

Returns true if a job scheduled date is reached. Otherwise, returns false.