Skip to content

Commit 69c6393

Browse files
authored
Merge pull request #8 from Kaligo/longkt90-patch-1
Allow to upgrade to sidekiq 8
2 parents cc857b4 + 279588e commit 69c6393

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+339
-255
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_PATH: "vendor/bundle"

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on: [push]
2+
jobs:
3+
tests:
4+
runs-on: ubuntu-latest
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
ruby:
9+
- "3.4"
10+
- "3.3"
11+
- "3.2"
12+
gemfile:
13+
- "Gemfile.sidekiq.7"
14+
- "Gemfile.sidekiq.8"
15+
env:
16+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
17+
RUBY_VERSION: $${ matrix.ruby }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
- name: Run unit tests
27+
run: bundle exec rspec

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.gem
22
*.gemspec.lock
3+
Gemfile.*.lock
4+
Gemfile.lock
5+
vendor/bundle/*

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Change Log
2+
## 2.4.0
3+
- Switch rspec to test for mutiple sidekiq version
4+
- Support both sidekiq 8 and 7
5+
26
## 2.3.0
37
- Add alert and prevent job run when user leaves optional params empty in between other non-empty optional params.
48

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'http://rubygems.org'
24

35
gemspec

Gemfile.sidekiq.7

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'http://rubygems.org'
2+
3+
gemspec
4+
5+
gem 'sidekiq', '~> 7.0'

Gemfile.sidekiq.8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'http://rubygems.org'
2+
3+
gemspec
4+
5+
gem 'sidekiq', '~> 8.0'

Jenkinsfile

Lines changed: 0 additions & 67 deletions
This file was deleted.

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rake'
24
require 'rspec/core/rake_task'
35

@@ -7,4 +9,4 @@ RSpec::Core::RakeTask.new(:spec) do |t|
79
end
810

911
desc 'Run tests'
10-
task :default => :spec
12+
task default: :spec

lib/sidekiq_adhoc_job.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'sidekiq'
24
require 'sidekiq/web'
35

@@ -10,7 +12,6 @@
1012
require 'sidekiq_adhoc_job/web'
1113

1214
module SidekiqAdhocJob
13-
1415
StringUtil ||= Utils::String
1516

1617
module Strategies
@@ -29,10 +30,20 @@ def self.config
2930
end
3031

3132
def self.init
32-
SidekiqAdhocJob::WorkerClassesLoader.load(@_config.module_names, load_paths: @_config.load_paths, strategy: @_config.strategy)
33+
SidekiqAdhocJob::WorkerClassesLoader.load(@_config.module_names, load_paths: @_config.load_paths,
34+
strategy: @_config.strategy)
35+
36+
# Check if we're using Sidekiq 8+ which requires the new API
37+
if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('8.0.0')
38+
Sidekiq::Web.configure do |config|
39+
config.register_extension(SidekiqAdhocJob::Web, name: 'Adhoc Jobs', tab: 'adhoc_jobs', index: 'adhoc-jobs')
40+
end
41+
else
42+
# Legacy API for Sidekiq 7.x
43+
Sidekiq::Web.register(SidekiqAdhocJob::Web)
44+
Sidekiq::Web.tabs['adhoc_jobs'] = 'adhoc-jobs'
45+
end
3346

34-
Sidekiq::Web.register(SidekiqAdhocJob::Web)
35-
Sidekiq::Web.tabs['adhoc_jobs'] = 'adhoc-jobs'
3647
Sidekiq::Web.locales << File.expand_path('sidekiq_adhoc_job/web/locales', __dir__)
3748

3849
assets_path = File.expand_path('sidekiq_adhoc_job/web/assets', __dir__)
@@ -41,11 +52,10 @@ def self.init
4152
root: assets_path,
4253
cascade: true,
4354
header_rules: [[:all, { 'cache-control' => 'private, max-age=86400' }]]
44-
45-
end
55+
end
4656

4757
def self.strategies
48-
@_strategies ||= []
58+
@strategies ||= []
4959
end
5060

5161
class Configuration
@@ -94,10 +104,10 @@ def strategy
94104
SidekiqAdhocJob::Strategies::Default.new(module_names)
95105
else
96106
strategy_klass = SidekiqAdhocJob::Strategies.const_get(StringUtil.camelize(strategy_name.to_s).to_s)
97-
raise InvalidConfigurationError, "Invalid strategy name" unless strategy_klass
107+
raise InvalidConfigurationError, 'Invalid strategy name' unless strategy_klass
108+
98109
strategy_klass.new(module_names)
99110
end
100111
end
101112
end
102-
103113
end

0 commit comments

Comments
 (0)