An extension to Sidekiq message processing to track your job results.
gem install sidekiq-result
Configure your middleware chains, lookup Middleware usage on Sidekiq wiki for more info.
require 'sidekiq' require 'sidekiq-result' .configure_server do |config| config.server_middleware do |chain| chain.add ::::, expiration: 30.minutes # default end config.client_middleware do |chain| chain.add ::::ClientMiddleware end end
After that you can use your jobs as usual and only include
Sidekiq::Result::Worker module if you want additional functionality of passing the job's finished stateto the client.
class MyJob include ::Worker include :::: def perform(*args) # your code goes here end end
To overwrite expiration on worker basis and don't use global expiration for all workers write a expiration method like this below:
class MyJob include ::Worker include :::: def expiration @expiration ||= 60*60*24*30 # 30 days end def perform(*args) # your code goes here end 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.
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake rspec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/chrismacnaughton/sidekiq_result.
The gem is available as open source under the terms of the MIT License.