-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remedy logic, gemfile, gemspec, CI #1
Changes from 6 commits
3f61386
d0bc6ed
014f1b0
ed404b5
8b20c9e
2d4e506
f1a192e
20e5c7f
35264bc
617268a
d57952d
2d31831
8096821
e348920
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: CI | ||
on: [pull_request, push] | ||
jobs: | ||
rubocop: | ||
strategy: | ||
fail-fast: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
bundler-cache: true | ||
- run: bundle exec rubocop | ||
rspec: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ruby: ['3.1', '3.2', '3.3'] | ||
runs-on: ubuntu-latest | ||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
- run: bundle exec rake |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
|
||
Gemfile.lock |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +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 'sentry-ruby' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
PATH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gemfile.lock for gems should be in .gitignore, odd that it was not there from the beginning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Robgra13 looks like you haven't deleted it |
||
remote: . | ||
specs: | ||
sidekiq-poison-pill-remedy (0.1.0) | ||
sidekiq | ||
|
||
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) | ||
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 | ||
regexp_parser (2.9.2) | ||
rspec (3.13.0) | ||
rspec-core (~> 3.13.0) | ||
rspec-expectations (~> 3.13.0) | ||
rspec-mocks (~> 3.13.0) | ||
rspec-core (3.13.1) | ||
rspec-support (~> 3.13.0) | ||
rspec-expectations (3.13.3) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-mocks (3.13.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-sidekiq (5.0.0) | ||
rspec-core (~> 3.0) | ||
rspec-expectations (~> 3.0) | ||
rspec-mocks (~> 3.0) | ||
sidekiq (>= 5, < 8) | ||
rspec-support (3.13.1) | ||
rubocop (1.66.1) | ||
json (~> 2.3) | ||
language_server-protocol (>= 3.17.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.3.0.2) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 2.4, < 3.0) | ||
rubocop-ast (>= 1.32.2, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.32.3) | ||
parser (>= 3.3.1.0) | ||
rubocop-performance (1.22.1) | ||
rubocop (>= 1.48.1, < 2.0) | ||
rubocop-ast (>= 1.31.1, < 2.0) | ||
rubocop-rake (0.6.0) | ||
rubocop (~> 1.0) | ||
rubocop-rspec (3.1.0) | ||
rubocop (~> 1.61) | ||
ruby-progressbar (1.13.0) | ||
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) | ||
unicode-display_width (2.6.0) | ||
|
||
PLATFORMS | ||
arm64-darwin-22 | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
rake (~> 13.0) | ||
rspec (~> 3.0) | ||
rspec-sidekiq | ||
rubocop (~> 1.40) | ||
rubocop-performance | ||
rubocop-rake | ||
rubocop-rspec | ||
sentry-ruby | ||
sidekiq-poison-pill-remedy! | ||
|
||
BUNDLED WITH | ||
2.4.18 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
# Sidekiq::Poison::Pill::Remedy | ||
# SidekiqPoisonPillRemedy | ||
|
||
TODO: Delete this and the text below, and describe your gem | ||
|
||
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sidekiq/poison/pill/remedy`. To experiment with that code, run `bin/console` for an interactive prompt. | ||
The Sidekiq Poison Pill Remedy gem enhances Sidekiq's job processing by automatically handling and rescheduling failed jobs (poison pills) with integrated logging and error tracking through Sentry, ultimately improving reliability and performance optimization. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI or own copywriting? ;P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted this to be pro so AI 🤖 |
||
## 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: | ||
|
||
`gem 'sidekiq-poison-pill-remedy'` | ||
|
||
Install the gem and add to the application's Gemfile by executing: | ||
And then execute: | ||
|
||
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG | ||
`$ bundle install` | ||
|
||
If bundler is not being used to manage dependencies, install the gem by executing: | ||
Or install it yourself as: | ||
|
||
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG | ||
`$ 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)` | ||
|
||
Azdaroth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Development | ||
|
||
|
@@ -28,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 | ||
|
||
|
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__) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'sidekiq_poison_pill_remedy' |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module SidekiqPoisonPillRemedy | ||
def self.remedy | ||
proc do |_jobstr, pill| | ||
next unless pill | ||
|
||
job = Sidekiq::DeadSet.new.find_job(pill.jid) | ||
|
||
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, | ||
job_item: job.item | ||
) | ||
else | ||
capture_sentry_message( | ||
"#{job.klass} was marked as `poison pill`, please create the job memory optimizations ticket timely", | ||
level: :warning, | ||
job_item: job.item | ||
) | ||
job.klass.constantize.set(queue: :poison_pill).perform_async(*job.args) | ||
job.delete | ||
end | ||
end | ||
end | ||
|
||
def self.capture_sentry_message(message, level:, job_item:) | ||
if defined?(Sentry) | ||
Sentry.capture_message( | ||
message, | ||
level: level, | ||
extra: { job_item: job_item } | ||
) | ||
end | ||
|
||
Sidekiq.logger.fatal(message) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module SidekiqPoisonPillRemedy | ||
module Version | ||
end | ||
VERSION = '0.1.0' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "lib/sidekiq/poison/pill/remedy/version" | ||
require_relative 'lib/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "sidekiq-poison-pill-remedy" | ||
spec.version = Sidekiq::Poison::Pill::Remedy::VERSION | ||
spec.authors = ["Karol Galanciak"] | ||
spec.email = ["[email protected]"] | ||
spec.name = 'sidekiq-poison-pill-remedy' | ||
spec.version = SidekiqPoisonPillRemedy::VERSION | ||
spec.authors = ['Karol Galanciak'] | ||
spec.email = ['[email protected]'] | ||
|
||
spec.summary = "TODO: Write a short summary, because RubyGems requires one." | ||
spec.description = "TODO: Write a longer description or delete this line." | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
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"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
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. | ||
|
@@ -29,13 +27,16 @@ 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' | ||
|
||
# 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 |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Robgra13 Best to reuse some existing template to have consistency across projects: https://github.com/BookingSync/rails-transactional-outbox/blob/master/.rubocop.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remember to remove the excluded files which don't exist in this gem ;)