Skip to content

Instantly share code, notes, and snippets.

@Alex-Karpov-878
Created March 28, 2020 17:48
Show Gist options
  • Save Alex-Karpov-878/898529aaaec03b2fecb77f986eff2373 to your computer and use it in GitHub Desktop.
Save Alex-Karpov-878/898529aaaec03b2fecb77f986eff2373 to your computer and use it in GitHub Desktop.
[Sidekiq 001.2] Installation and First Job - DailyDrip
# 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