Created
March 28, 2020 17:48
-
-
Save Alex-Karpov-878/898529aaaec03b2fecb77f986eff2373 to your computer and use it in GitHub Desktop.
[Sidekiq 001.2] Installation and First Job - DailyDrip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# worker.rb | |
require 'sidekiq' | |
Sidekiq.configure_client do |config| | |
config.redis = {db: 1 } | |
end | |
Sidekiq.configure_server do |config| | |
config.redis = {db: 1 } | |
end | |
class OurWorker | |
include Sidekiq::Worker | |
def perform(complexity) | |
case complexity | |
when "super_hard" | |
sleep 20 | |
puts "Really took quite a bit of effort" | |
when "hard" | |
sleep 10 | |
puts "That was a bit of work" | |
else | |
sleep 1 | |
"That wasn't a lot of effort" | |
end | |
end | |
end | |
# bundle exec sidekiq -r ./worker.rb | |
# bundle exec irb -r ./worker.rb | |
## OurWorker.perform_async("easy") | |
## OurWorker.perform_in(5, "easy") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment