Exq (exq v0.23.0)
View SourceSummary
Functions
Enqueue a job immediately.
Schedule multiple jobs to be atomically enqueued at specific times
Schedule a job to be enqueued at a specific time in the future.
Schedule a job to be enqueued at in the future given by offset in seconds.
Callback implementation for Application.start/2.
Subscribe to a queue - ie. listen to queue for jobs
List all subscriptions(active queues)
Unsubscribe from a queue - ie. stop listening to queue for jobs
Unsubscribe from all queues - ie. stop listening for jobs
Get the job metadata
Functions
Enqueue a job immediately.
Expected args:
pid- PID for Exq Manager or Enqueuer to handle thisqueue- Name of queue to useworker- Worker module to targetargs- Array of args to send to workeroptions: Following job options are supportedmax_retries(integer) - max retry countjid(string) - user supplied jid valueunique_for(integer) - lock expiration duration in secondsunique_token(string) - unique lock token. By default the token is computed based on the queue, class and args.unique_until(atom) - defaults to:success. Supported values are:success- unlock on job success:start- unlock on job first execution:expiry- unlock when the lock is expired. Depends onunique_forvalue.
Returns:
{:ok, jid}if the job was enqueued successfully, withjid= Job ID.{:error, reason}if there was an error enqueueing job
Schedule multiple jobs to be atomically enqueued at specific times
Expected args:
pid- PID for Exq Manager or Enqueuer to handle thisjobs- List of jobs each defined as[queue, worker, args, options]queue- Name of queue to useworker- Worker module to targetargs- Array of args to send to workeroptions: Following job options are supportedmax_retries(integer) - max retry countjid(string) - user supplied jid valueunique_for(integer) - lock expiration duration in secondsunique_token(string) - unique lock token. By default the token is computed based on the queue, class and args.unique_until(atom) - defaults to:success. Supported values are:success- unlock on job success:start- unlock on job first execution:expiry- unlock when the lock is expired. Depends onunique_forvalue.
schedule- (optional) - used to schedule the job for future. If not present, job will be enqueued immediately by default.{:in, seconds_from_now}{:at, datetime}
Schedule a job to be enqueued at a specific time in the future.
Expected args:
pid- PID for Exq Manager or Enqueuer to handle thisqueue- name of queue to usetime- Time to enqueueworker- Worker module to targetargs- Array of args to send to workeroptions: Following job options are supportedmax_retries(integer) - max retry countjid(string) - user supplied jid valueunique_for(integer) - lock expiration duration in secondsunique_token(string) - unique lock token. By default the token is computed based on the queue, class and args.unique_until(atom) - defaults to:success. Supported values are:success- unlock on job success:start- unlock on job first execution:expiry- unlock when the lock is expired. Depends onunique_forvalue.
If Exq is running in mode: [:enqueuer], then you will need to use the Enqueuer
to schedule jobs, for example:
time = Timex.now() |> Timex.shift(days: 8)
Exq.Enqueuer.enqueue_at(Exq.Enqueuer, "default", time, MyWorker, ["foo"])
Schedule a job to be enqueued at in the future given by offset in seconds.
Expected args:
pid- PID for Exq Manager or Enqueuer to handle thisqueue- Name of queue to useoffset- Offset in seconds in the future to enqueueworker- Worker module to targetargs- Array of args to send to workeroptions: Following job options are supportedmax_retries(integer) - max retry countjid(string) - user supplied jid valueunique_for(integer) - lock expiration duration in secondsunique_token(string) - unique lock token. By default the token is computed based on the queue, class and args.unique_until(atom) - defaults to:success. Supported values are:success- unlock on job success:start- unlock on job first execution:expiry- unlock when the lock is expired. Depends onunique_forvalue.
If Exq is running in mode: [:enqueuer], then you will need to use the Enqueuer
to schedule jobs, for example:
Exq.Enqueuer.enqueue_in(Exq.Enqueuer, "default", 5000, MyWorker, ["foo"])
Callback implementation for Application.start/2.
Subscribe to a queue - ie. listen to queue for jobs
pid- PID for Exq Manager or Enqueuer to handle thisqueue- Name of queueconcurrency- Optional argument specifying max concurrency for queue
List all subscriptions(active queues)
pid- PID for Exq Manager or Enqueuer to handle this
Unsubscribe from a queue - ie. stop listening to queue for jobs
pid- PID for Exq Manager or Enqueuer to handle thisqueue- Name of queue
Unsubscribe from all queues - ie. stop listening for jobs
pid- PID for Exq Manager or Enqueuer to handle this
Get the job metadata
name- registered name of Exq. Only necessary if the custom name option is used when starting Exq. Defaults to Exqpid- pid of the worker. Defaults to self().