sidekiq-canary 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +24 -0
- data/README.md +4 -0
- data/Rakefile +6 -0
- data/lib/sidekiq-canary.rb +1 -0
- data/lib/sidekiq/canary.rb +21 -0
- data/lib/sidekiq/canary/version.rb +5 -0
- data/sidekiq-canary.gemspec +23 -0
- data/spec/canary_spec.rb +43 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/worker.rb +19 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e1d70babb0731334a12b32373daf2ec13ca6c1e5
|
4
|
+
data.tar.gz: 459773c95cf6d8315d9cd378acc0b5045c55381d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18b96079386ac88bf0cc2d933eb48dac506e2eb729caa8318540d1660de213f3b5f5e2f6c9ba32ac342766dca2a232e3403ddf433a183c4d6a361a6d830e37c4
|
7
|
+
data.tar.gz: fdcc0401f4f20cb6b5ef4584f89b4c5b962cb2ba20144254e80f342fcda72767ccdf05ac0de2aa8594c8cd372de97b95573b28cb56797b1480cb9dd75696e317
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sidekiq-canary (0.0.1)
|
5
|
+
sidekiq (~> 3.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
celluloid (0.17.3)
|
11
|
+
celluloid-essentials
|
12
|
+
celluloid-extras
|
13
|
+
celluloid-fsm
|
14
|
+
celluloid-pool
|
15
|
+
celluloid-supervision
|
16
|
+
timers (>= 4.1.1)
|
17
|
+
celluloid-essentials (0.20.5)
|
18
|
+
timers (>= 4.1.1)
|
19
|
+
celluloid-extras (0.20.5)
|
20
|
+
timers (>= 4.1.1)
|
21
|
+
celluloid-fsm (0.20.5)
|
22
|
+
timers (>= 4.1.1)
|
23
|
+
celluloid-pool (0.20.5)
|
24
|
+
timers (>= 4.1.1)
|
25
|
+
celluloid-supervision (0.20.5)
|
26
|
+
timers (>= 4.1.1)
|
27
|
+
connection_pool (2.2.0)
|
28
|
+
diff-lcs (1.2.5)
|
29
|
+
hitimes (1.2.4)
|
30
|
+
json (1.8.3)
|
31
|
+
redis (3.3.0)
|
32
|
+
redis-namespace (1.5.2)
|
33
|
+
redis (~> 3.0, >= 3.0.4)
|
34
|
+
rspec (3.4.0)
|
35
|
+
rspec-core (~> 3.4.0)
|
36
|
+
rspec-expectations (~> 3.4.0)
|
37
|
+
rspec-mocks (~> 3.4.0)
|
38
|
+
rspec-core (3.4.4)
|
39
|
+
rspec-support (~> 3.4.0)
|
40
|
+
rspec-expectations (3.4.0)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.4.0)
|
43
|
+
rspec-mocks (3.4.1)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.4.0)
|
46
|
+
rspec-support (3.4.1)
|
47
|
+
sidekiq (3.5.4)
|
48
|
+
celluloid (~> 0.17.2)
|
49
|
+
connection_pool (~> 2.2, >= 2.2.0)
|
50
|
+
json (~> 1.0)
|
51
|
+
redis (~> 3.2, >= 3.2.1)
|
52
|
+
redis-namespace (~> 1.5, >= 1.5.2)
|
53
|
+
timers (4.1.1)
|
54
|
+
hitimes
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
rspec
|
61
|
+
sidekiq-canary!
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.12.1
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2016 Damien Mathieu
|
2
|
+
|
3
|
+
Portions of initial project skeleton are copyright (c) 2012 Gabe Evans
|
4
|
+
|
5
|
+
MIT License
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'sidekiq/canary'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Canary
|
3
|
+
def get_sidekiq_options
|
4
|
+
options = super
|
5
|
+
options.merge('queue' => queue(options["queue"]))
|
6
|
+
end
|
7
|
+
|
8
|
+
def queue(default)
|
9
|
+
use_canary_queue?(default) ? "#{default}_canary" : default
|
10
|
+
end
|
11
|
+
|
12
|
+
def use_canary_queue?(default)
|
13
|
+
rand(100) < canary_percent(default)
|
14
|
+
end
|
15
|
+
|
16
|
+
def canary_percent(default)
|
17
|
+
ENV["#{default.upcase}_CANARY_PERCENT"].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'sidekiq/canary/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'sidekiq-canary'
|
7
|
+
gem.version = Sidekiq::Canary::VERSION
|
8
|
+
gem.authors = ['Damien Mathieu']
|
9
|
+
gem.email = ['42@dmathieu.com']
|
10
|
+
gem.description = %q{Sidekiq canary deployments}
|
11
|
+
gem.summary = %q{Sidekiq Canary allows you to do canary deployments with your sidekiq workers}
|
12
|
+
gem.homepage = 'https://github.com/dmathieu/sidekiq-canary'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'sidekiq', '~> 3.0'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
end
|
data/spec/canary_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sidekiq::Canary do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
RegularSpecWorker.jobs.clear
|
7
|
+
OtherQueueSpecWorker.jobs.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
it "runs the worker" do
|
11
|
+
expect do
|
12
|
+
RegularSpecWorker.perform_async
|
13
|
+
end.to change(RegularSpecWorker.jobs, :size).by(1)
|
14
|
+
expect(RegularSpecWorker.jobs.first["queue"]).to eql("default")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "runs the worker on the canary queue" do
|
18
|
+
allow(ENV).to receive(:[]).and_call_original
|
19
|
+
allow(ENV).to receive(:[]).with("DEFAULT_CANARY_PERCENT").and_return(100)
|
20
|
+
|
21
|
+
expect do
|
22
|
+
RegularSpecWorker.perform_async
|
23
|
+
end.to change(RegularSpecWorker.jobs, :size).by(1)
|
24
|
+
expect(RegularSpecWorker.jobs.first["queue"]).to eql("default_canary")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "runs a worker on another queue" do
|
28
|
+
expect do
|
29
|
+
OtherQueueSpecWorker.perform_async
|
30
|
+
end.to change(OtherQueueSpecWorker.jobs, :size).by(1)
|
31
|
+
expect(OtherQueueSpecWorker.jobs.first["queue"]).to eql("critical")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "runs the worker on the canary queue" do
|
35
|
+
allow(ENV).to receive(:[]).and_call_original
|
36
|
+
allow(ENV).to receive(:[]).with("CRITICAL_CANARY_PERCENT").and_return(100)
|
37
|
+
|
38
|
+
expect do
|
39
|
+
OtherQueueSpecWorker.perform_async
|
40
|
+
end.to change(OtherQueueSpecWorker.jobs, :size).by(1)
|
41
|
+
expect(OtherQueueSpecWorker.jobs.first["queue"]).to eql("critical_canary")
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'sidekiq/testing'
|
6
|
+
require 'sidekiq/canary'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# Run specs in random order to surface order dependencies. If you find an
|
10
|
+
# order dependency and want to debug it, you can fix the order by providing
|
11
|
+
# the seed, which is printed after each run.
|
12
|
+
# --seed 1234
|
13
|
+
config.order = 'random'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Requires supporting files with custom matchers and macros, etc,
|
17
|
+
# in ./support/ and its subdirectories.
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class RegularSpecWorker
|
2
|
+
include Sidekiq::Worker
|
3
|
+
extend Sidekiq::Canary
|
4
|
+
|
5
|
+
def perform
|
6
|
+
# no-op
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class OtherQueueSpecWorker
|
11
|
+
include Sidekiq::Worker
|
12
|
+
extend Sidekiq::Canary
|
13
|
+
|
14
|
+
sidekiq_options queue: 'critical'
|
15
|
+
|
16
|
+
def perform
|
17
|
+
# no-op
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-canary
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Damien Mathieu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Sidekiq canary deployments
|
42
|
+
email:
|
43
|
+
- 42@dmathieu.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/sidekiq-canary.rb
|
55
|
+
- lib/sidekiq/canary.rb
|
56
|
+
- lib/sidekiq/canary/version.rb
|
57
|
+
- sidekiq-canary.gemspec
|
58
|
+
- spec/canary_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
- spec/support/worker.rb
|
61
|
+
homepage: https://github.com/dmathieu/sidekiq-canary
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.5.1
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Sidekiq Canary allows you to do canary deployments with your sidekiq workers
|
85
|
+
test_files:
|
86
|
+
- spec/canary_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/support/worker.rb
|
89
|
+
has_rdoc:
|