-
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
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3f61386
remedy logic, gemfile, gemspec, CI
Robgra13 d0bc6ed
add-platform x86_64-linux
Robgra13 014f1b0
changes according to review, rubocop, readme
Robgra13 ed404b5
gemspec edit
Robgra13 8b20c9e
spec edit
Robgra13 2d4e506
changes in spec
Robgra13 f1a192e
another spec version
Robgra13 20e5c7f
spec changed according to last comment
Robgra13 35264bc
write basic specs ; clean up setup and file structure
Azdaroth 617268a
Sentry message
Robgra13 d57952d
Sentry spec fix
Robgra13 2d31831
added logging test
Robgra13 8096821
readme edit, lib/jobs delete
Robgra13 e348920
and_call_original fix in spec
Robgra13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
|
||
# Ignore Gemfile.lock | ||
Gemfile.lock |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
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: 15 | ||
Exclude: | ||
- 'lib/sidekiq_poison_pill_remedy.rb' | ||
|
||
|
||
Metrics/MethodLength: | ||
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 | ||
|
||
|
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
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
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
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__) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "sidekiq" | ||
Robgra13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class MyJob | ||
include Sidekiq::Job | ||
sidekiq_options retry: 1 | ||
|
||
def perform(arg) | ||
raise StandardError, "Forced failure for testing" if arg == "fail" | ||
end | ||
end |
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
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.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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:, | ||
extra: { job_item: } | ||
) | ||
end | ||
|
||
Sidekiq.logger.fatal(message) | ||
end | ||
end |
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
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" | ||
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. given that this is only for testing, please don't include this on a gem level, but rather on a spec_helper level |
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
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 |
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
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.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.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.required_ruby_version = ">= 3.1.0" | ||
|
||
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["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. | ||
|
@@ -35,7 +33,9 @@ Gem::Specification.new do |spec| | |
|
||
# Uncomment to register a new dependency of your gem | ||
# spec.add_dependency "example-gem", "~> 1.0" | ||
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" | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
AI or own copywriting? ;P
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.
I wanted this to be pro so AI 🤖