Skip to content

Commit

Permalink
another spec version
Browse files Browse the repository at this point in the history
  • Loading branch information
Robgra13 committed Oct 24, 2024
1 parent 2d4e506 commit f1a192e
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 165 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
# rspec failure tracking
.rspec_status

# Ignore Gemfile.lock
Gemfile.lock
114 changes: 110 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,114 @@
Style/Documentation:
Enabled: false
require:
- rubocop-performance
- rubocop-rspec

inherit_mode:
merge:
- Exclude

AllCops:
NewCops: enable
TargetRubyVersion: 3.1
Exclude:
- "db/**/*"
- "bin/**/*"
- "tmp/**/*"
- "log/**/*"
- "vendor/**/*"
- "spec/rails_helper.rb"

Layout/FrozenStringLiteralComment:
Enabled: true

Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation

Layout/ArrayAlignment:
EnforcedStyle: with_fixed_indentation

Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/FirstArgumentIndentation:
EnforcedStyle: consistent

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation

Layout/SpaceBeforeBrackets:
Enabled: false


Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true

Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'


Naming/FileName:
EnforcedStyle: snake_case
Exclude:
- 'lib/sidekiq-poison-pill-remedy.rb'

Naming/VariableNumber:
EnforcedStyle: snake_case


RSpec/MultipleExpectations:
Max: 20

RSpec/NestedGroups:
Max: 10

RSpec/ExampleLength:
Max: 15
Exclude:
- 'spec/sidekiq_poison_pill_remedy_spec.rb'

RSpec/VerifiedDoubles:
Exclude:
- 'spec/**/*.rb'


Metrics/AbcSize:
Max: 19
Max: 15
Exclude:
- 'lib/sidekiq_poison_pill_remedy.rb'


Metrics/MethodLength:
Max: 20
Max: 20

Metrics/BlockLength:
Exclude:
- 'lib/sidekiq_poison_pill_remedy.rb'

Layout/LineLength:
Max: 125


Style/StringLiterals:
EnforcedStyle: double_quotes
ConsistentQuotesInMultiline: true

Style/Documentation:
Enabled: false


20 changes: 12 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# 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 'rubocop', '~> 1.40', require: false
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'sentry-ruby'
gem "rake", "~> 13.0"
gem "sentry-ruby"

group :development, :test do
gem "rspec", "~> 3.0"
gem "rspec-sidekiq"
gem "rubocop", "~> 1.40", require: false
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
end
94 changes: 0 additions & 94 deletions Gemfile.lock

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ Or install it yourself as:

The gem is supposed to be used in the following way when added to the application

Check Sidekiq super_fetch:[here](https://github.com/sidekiq/sidekiq/wiki/Reliability#using-super_fetch)

Remedy is supposed to be use like:
`config.super_fetch!(&SidekiqPoisonPillRemedy.remedy)`

When a job fails, the SidekiqPoisonPillRemedy captures the failure and determines whether the job should be moved to a dedicated poison_pill queue.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
12 changes: 12 additions & 0 deletions lib/jobs/my_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "sidekiq"

class MyJob
include Sidekiq::Job
sidekiq_options retry: 1

def perform(arg)
raise StandardError, "Forced failure for testing" if arg == "fail"
end
end
2 changes: 1 addition & 1 deletion lib/sidekiq-poison-pill-remedy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

require 'sidekiq_poison_pill_remedy'
require "sidekiq_poison_pill_remedy"
6 changes: 3 additions & 3 deletions lib/sidekiq_poison_pill_remedy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.remedy

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 All @@ -29,8 +29,8 @@ def self.capture_sentry_message(message, level:, job_item:)
if defined?(Sentry)
Sentry.capture_message(
message,
level: level,
extra: { job_item: job_item }
level:,
extra: { job_item: }
)
end

Expand Down
8 changes: 8 additions & 0 deletions lib/sidekiq_worker_loader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require "sidekiq"
require "sidekiq/api"
require "sidekiq/testing"
require "rspec-sidekiq"
require "sidekiq-poison-pill-remedy"
require_relative "jobs/my_job"
2 changes: 1 addition & 1 deletion lib/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
module SidekiqPoisonPillRemedy
module Version
end
VERSION = '0.1.0'
VERSION = "0.1.0"
end
29 changes: 14 additions & 15 deletions sidekiq-poison-pill-remedy.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# frozen_string_literal: true

require_relative 'lib/version'
require_relative "lib/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 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.homepage = "https://github.com/BookingSync/sidekiq-poison-pill-remedy"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.1.0"

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'
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 @@ -27,16 +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 'sidekiq'
spec.add_development_dependency 'rspec-sidekiq'
spec.add_dependency "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'
spec.metadata["rubygems_mfa_required"] = "true"
end
Loading

0 comments on commit f1a192e

Please sign in to comment.