Sidekiq Client class for mruby.
Sidekiq is a simple, efficient background processing for CRuby and JRuby.
This mrbgem provides Sidekiq worker module for mruby. Your mruby code can register background jobs to Redis server, and Sidekiq server (works on CRuby and JRuby) take out and process the jobs.
- Add a worker to process jobs asynchronously:
class HardWorker
include Sidekiq::Worker
end
You don't have to implement perform
method. But you must prepare a same name class that has perform
method for Sidekiq server.
- Create a job to be processed asynchronously:
HardWorker.perform_async('bob', 5)
You can also create a job to be processed in the future:
HardWorker.perform_in(300, 'bob', 5) # process after 300 sec
Sidekiq.configure_client do |config|
config.redis = { host: 'localhost', port: 6379 }
config.default_worker_options = { queue: 'default', retry: true }
end
You can specify options in every worker.
class HardWorker
include Sidekiq::Worker
sidekiq_options queue: 'default', retry: true
end
- add conf.gem line to
build_config.rb
MRuby::Build.new do |conf|
# ... (snip) ...
conf.gem :github => 'monochromegane/mruby-sidekiq-client'
end