-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Job Format
Mike Perham edited this page Jul 29, 2013
·
15 revisions
Sidekiq serializes jobs to Redis in JSON format. Each Job is a simple Hash of data.
At bare minimum, a job requires three fields:
{
"class": "SomeWorker",
"jid": <12-byte random number as 24 char hex string>,
"args": [1, "arg", true]
}
args
is splatted onto the worker class's perform
method.
When a job is serialized, the options for the Worker are serialized as part of the job payload:
{
"queue": "default",
"retry": true
}
The at
element stores when a job was scheduled to execute, in Unix epoch format:
{
"at": 1234567890.123
}
Sidekiq's retry feature adds several elements to the job payload:
{
"retry_count": 2, // number of times we've retried so far
"error_message": "wrong number of arguments (2 for 3)", // the exception message
"error_class": "ArgumentError", // the exception class
"error_backtrace": ["line 0", "line 1", ...], // some or all of the exception's backtrace, optional, array of strings
"failed_at": "2013-07-29 03:26:41 UTC", // the first time the job failed
"retried_at": "2013-07-29 03:26:56 UTC" // the last time the job failed
}
The two times are stored as Strings in Ruby's default format Time.now.utc.to_s
.