Created
March 29, 2020 01:01
-
-
Save Alex-Karpov-878/699dd59bffc425139bcd4ab0d3a0e9e9 to your computer and use it in GitHub Desktop.
Sidekiq with web interface and no retry
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
# frozen_string_literal: true | |
require 'sidekiq' | |
Sidekiq.configure_client { |config| config.redis = { db: 1 } } | |
require 'sidekiq/web' | |
run Sidekiq::Web | |
# bundle exec rackup |
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
source 'https://rubygems.org' | |
gem 'sidekiq' | |
gem 'rack' | |
gem 'sinatra' |
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
# frozen_string_literal: true | |
# 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 | |
sidekiq_options retry: 0 # dies if failed | |
def perform(complexity) | |
case complexity | |
when 'super_hard' | |
puts 'Charging a credit card' | |
raise 'Whops stuff got bad' | |
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