sidewalk v0.2.2 Sidewalk.Client
The Client module contains functions to interact with the Redis server and to enqueue jobs in the format Sidekiq uses. Like Sidekiq or Resque it supports three types of enqueuing.
- Enquing with an immediate execution
- Enquing with an execution delay defined in seconds
- Enquing with an explicit execution at a given unix timestamp
For more information of the structure of a Sidewalk job, please have a look at the Job
module.
Summary
Functions
Jobs enqueued with this function will be executed by Sidekiq as soon as possible
Jobs enqueued with this function will be executed by Sidekiq at a given unix timestamp
Jobs enqueued with this function will be executed by Sidekiq after a defined delay in seconds
Types
Functions
Jobs enqueued with this function will be executed by Sidekiq as soon as possible.
Example
# Enqueue a job which should be executed immediately
job = %Sidewalk.Job{class: "MyWorker", args: ['bob', 1, %{foo: 'bar'}]}
{:ok, jid} = Sidewalk.Client.enqueue(job) # => jid: "2f87a952ced00ea6cdd61245"
enqueue_at(job, enqueue_time) :: response
Jobs enqueued with this function will be executed by Sidekiq at a given unix timestamp.
Example
# Enquing a job which would be executed at 31th December 2018 (unix timestamp: 1546293600)
job = %Sidewalk.Job{class: "MyWorker", args: ['bob', 1, %{foo: 'bar'}]}
{:ok, jid} = Sidewalk.Client.enqueue_at(job, 1546293600) # => jid: "d6ceac7d6c42d35ff6cac8a0"
Jobs enqueued with this function will be executed by Sidekiq after a defined delay in seconds.
Example
# Enquing a job which would be executed in 2 minutes (120 seconds) from now
job = %Sidewalk.Job{class: "MyWorker", args: ['bob', 1, %{foo: 'bar'}]}
{:ok, jid} = Sidewalk.Client.enqueue_in(job, 120) # => jid: "a805893e8bd98bf965d1dd54"