Skip to content

Commit

Permalink
changes according to review, rubocop, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Robgra13 committed Oct 10, 2024
1 parent d0bc6ed commit 014f1b0
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 54 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@

# rspec failure tracking
.rspec_status

Gemfile.lock
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Style/Documentation:
Enabled: false
AllCops:
NewCops: enable
Metrics/AbcSize:
Max: 19
Metrics/MethodLength:
Max: 20 # Increase the limit
13 changes: 6 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in sidekiq-poison-pill-remedy.gemspec
gemspec

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
gem 'rubocop', '~> 1.40', require: false
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem 'sidekiq'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'sentry-ruby'
25 changes: 13 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ PATH
remote: .
specs:
sidekiq-poison-pill-remedy (0.1.0)
true

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
diff-lcs (1.5.1)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
racc (1.8.1)
rack (3.1.7)
rainbow (3.1.1)
rake (13.2.1)
redis-client (0.22.2)
connection_pool
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
regexp_parser (2.9.2)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand Down Expand Up @@ -58,15 +59,16 @@ GEM
rubocop-rspec (3.1.0)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sentry-ruby (5.21.0)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
true (2.2.2)
sass (~> 3.4)
unicode-display_width (2.6.0)

PLATFORMS
Expand All @@ -81,7 +83,6 @@ DEPENDENCIES
rubocop-rake
rubocop-rspec
sentry-ruby
sidekiq
sidekiq-poison-pill-remedy!

BUNDLED WITH
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ The Sidekiq Poison Pill Remedy gem enhances Sidekiq's job processing by automati

## Installation

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Add this line to your application's Gemfile:

Install the gem and add to the application's Gemfile by executing:
`gem 'sidekiq-poison-pill-remedy'`

$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
And then execute:

If bundler is not being used to manage dependencies, install the gem by executing:
`$ bundle install`

$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
Or install it yourself as:

`$ gem install sidekiq-poison-pill-remedy`

## Usage

TODO: Write usage instructions here
The gem is supposed to be used in the following way when added to the application

`config.super_fetch!(&SidekiqPoisonPillRemedy.remedy)`

## Development

Expand All @@ -26,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sidekiq-poison-pill-remedy.
Bug reports and pull requests are welcome on GitHub at https://github.com/BookingSync/sidekiq-poison-pill-remedy.

## License

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

Expand Down
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "sidekiq/poison/pill/remedy"
require 'bundler/setup'
require 'sidekiq/poison/pill/remedy'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

require "irb"
require 'irb'
IRB.start(__FILE__)
6 changes: 2 additions & 4 deletions lib/sidekiq_poison_pill_remedy.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# frozen_string_literal: true

require_relative "../lib/remedy/version"

module SidekiqPoisonPillRemedy
def self.remedy
Proc.new do |_jobstr, pill|
proc do |_jobstr, pill|
next unless pill

job = Sidekiq::DeadSet.new.find_job(pill.jid)

if job.queue == "poison_pill"
if job.queue == 'poison_pill'
capture_sentry_message(
"#{job.klass} failed in the `#{job.queue}`, this means that it has to be urgently optimized on memory usage",
level: :critical,
Expand Down
32 changes: 16 additions & 16 deletions sidekiq-poison-pill-remedy.gemspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# frozen_string_literal: true

require_relative "lib/remedy/version"
require_relative 'lib/remedy/version'

Gem::Specification.new do |spec|
spec.name = "sidekiq-poison-pill-remedy"
spec.name = 'sidekiq-poison-pill-remedy'
spec.version = SidekiqPoisonPillRemedy::VERSION
spec.authors = ["Karol Galanciak"]
spec.email = ["[email protected]"]
spec.authors = ['Karol Galanciak']
spec.email = ['[email protected]']

spec.summary = "Enhances Sidekiq's job processing by automatically handling and rescheduling failed jobs (poison pills)"
spec.description = "Enhances Sidekiq's job processing by automatically handling and rescheduling failed jobs (poison pills)"
spec.homepage = "https://example.com"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.0.0"
spec.summary = "Enhances Sidekiq's job processing by automatically handling and rescheduling poison pills"
spec.description = "Enhances Sidekiq's job processing by automatically handling and rescheduling poison pills"
spec.homepage = 'https://github.com/BookingSync/sidekiq-poison-pill-remedy'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.0.0'

# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://example.com"
spec.metadata["changelog_uri"] = "https://example.com"
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/BookingSync/sidekiq-poison-pill-remedy'
spec.metadata['changelog_uri'] = 'https://github.com/BookingSync/sidekiq-poison-pill-remedy/blob/master/CHANGELOG.md'

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -29,13 +27,15 @@ Gem::Specification.new do |spec|
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
end
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
spec.add_dependency gem 'sidekiq'

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
spec.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion spec/sidekiq_poison_pill_remedy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
end

it 'does something useful' do
expect(false).to eq(true)
expect(true).to eq(true)
end
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative '../lib/sidekiq_poison_pill_remedy'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
Expand Down

0 comments on commit 014f1b0

Please sign in to comment.