README.md in sidekiq-status-0.5.4 vs README.md in sidekiq-status-0.6.0
- old
+ new
@@ -1,9 +1,11 @@
# Sidekiq::Status
[](http://badge.fury.io/rb/sidekiq-status)
[](https://codeclimate.com/github/utgarda/sidekiq-status)
[](http://travis-ci.org/utgarda/sidekiq-status)
+[](https://gemnasium.com/utgarda/sidekiq-status)
+[](http://inch-ci.org/github/utgarda/sidekiq-status)
An extension to [Sidekiq](http://github.com/mperham/sidekiq) message processing to track your jobs. Inspired
by [resque-status](http://github.com/quirkey/resque-status) and mostly copying its features, using Sidekiq's middleware.
## Installation
@@ -21,20 +23,23 @@
require 'sidekiq'
require 'sidekiq-status'
Sidekiq.configure_client do |config|
config.client_middleware do |chain|
- chain.add Sidekiq::Status::ClientMiddleware
+ # accepts :expiration (optional)
+ chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes # default
end
end
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
+ # accepts :expiration (optional)
chain.add Sidekiq::Status::ServerMiddleware, expiration: 30.minutes # default
end
config.client_middleware do |chain|
- chain.add Sidekiq::Status::ClientMiddleware
+ # accepts :expiration (optional)
+ chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes # default
end
end
```
After that you can use your jobs as usual and only include `Sidekiq::Status::Worker` module if you want additional functionality of tracking progress and passing any data from job to client.
@@ -65,25 +70,36 @@
end
```
But keep in mind that such thing will store details of job as long as expiration is set, so it may charm your Redis storage/memory consumption. Because Redis stores all data in RAM.
+### What is expiration time ?
+As you noticed you can set expiration time for jobs globally by expiration option while adding middleware or writing a expiration method on each worker this expiration time is nothing but
+
++ [Redis expire time](http://redis.io/commands/expire), also know as TTL(time to live)
++ After expiration time all the info like status, update_time etc. about the worker disappears.
++ It is advised to set this expiration time greater than time required for completion of the job.
++ Default expiration time is 30 minutes.
+
### Retrieving status
Query for job status any time later:
``` ruby
job_id = MyJob.perform_async(*args)
-# :queued, :working, :complete or :failed , nil after expiry (30 minutes)
+# :queued, :working, :complete, :failed or :interrupted, nil after expiry (30 minutes)
status = Sidekiq::Status::status(job_id)
-Sidekiq::Status::queued? job_id
-Sidekiq::Status::working? job_id
-Sidekiq::Status::complete? job_id
-Sidekiq::Status::failed? job_id
+Sidekiq::Status::queued? job_id
+Sidekiq::Status::working? job_id
+Sidekiq::Status::complete? job_id
+Sidekiq::Status::failed? job_id
+Sidekiq::Status::interrupted? job_id
+
```
+Important: If you try any of the above status method after the expiration time, will result into `nil` or `false`
-### Tracking progress, saving and retrieveing data associated with job
+### Tracking progress, saving, and retrieving data associated with job
``` ruby
class MyJob
include Sidekiq::Worker
include Sidekiq::Status::Worker # Important!
@@ -116,17 +132,25 @@
### Unscheduling
```ruby
scheduled_job_id = MyJob.perform_in 3600
Sidekiq::Status.cancel scheduled_job_id #=> true
-#doesn't cancel running jobs, this is more like unscheduling, therefore an alias:
+# doesn't cancel running jobs, this is more like unscheduling, therefore an alias:
Sidekiq::Status.unschedule scheduled_job_id #=> true
+
+# returns false if invalid or wrong scheduled_job_id is provided
+Sidekiq::Status.unschedule some_other_unschedule_job_id #=> false
+Sidekiq::Status.unschedule nil #=> false
+Sidekiq::Status.unschedule '' #=> false
+# Note: cancel and unschedule are alias methods.
```
+Important: If you try any of the status method after the expiration time for scheduled jobs, will result into `nil` or `false`. But job will be in sidekiq's scheduled queue and will execute normally, once job is started on scheduled time you will get status info for job till expiration time defined on `Sidekiq::Status::ServerMiddleware`.
### Sidekiq web integration
-Sidekiq::Status also provides an extension to Sidekiq web interface with a `/statuses` page.
+Sidekiq::Status also provides an extension to Sidekiq web interface with a `/statuses`.
+
Setup Sidekiq web interface according to Sidekiq documentation and add the Sidekiq::Status::Web require:
``` ruby
require 'sidekiq/web'
@@ -156,9 +180,10 @@
### Features coming
* Stopping jobs by id
## Thanks
+* Pramod Shinde
* Clay Allsopp
* Andrew Korzhuev
* Jon Moses
* Wayne Hoover
* Dylan Robinson