sidewalk v0.2.0 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

enqueue(arg1)

Specs

enqueue(job) :: response

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, "2f87a952ced00ea6cdd61245"} = Sidewalk.Client.enqueue(job)
enqueue_at(job, enqueue_at_timestamp \\ current_unix_timestamp + 60)

Specs

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, "d6ceac7d6c42d35ff6cac8a0"} = Sidewalk.Client.enqueue_at(job, 1546293600)
enqueue_in(job, enqueue_in_seconds \\ 60)

Specs

enqueue_in(job, enqueue_delay) :: response

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, "a805893e8bd98bf965d1dd54"} = Sidewalk.Client.enqueue_in(job, 120)