capistrano-sidekiq-scheduler-roles 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aba68c1fa3c9ad5db6c6a4b8e026e0f204b322b0df096807e962f83ffe1354ef
4
+ data.tar.gz: 43c2d5129beacf8beeea640587d3c5d9dfdfc11d6878131624f67b9885abf785
5
+ SHA512:
6
+ metadata.gz: 6eb1a97c9434ed4c54014bce9e2162784662623299bbb99e47612e4d7dd68e9d355a187450b402c9bbe48e2544e226534cb0165378c41f918bc362b80f82c005
7
+ data.tar.gz: bcdbaf2169144c92a35fe34cff2d17e8f5e3efa4383f8ab439bfe1d453757d0790482de960adb9b93bba8a17c3e8595361edf2420e0ba334a2707aa7340204fc
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| 'https://github.com/#{repo_name}' }
4
+
5
+ # Specify your gem's dependencies in capistrano-sidekiq-scheduler-roles.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 past-one
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ ## capistrano-sidekiq-scheduler-roles
2
+
3
+ A gem for configuring sidekiq-scheduler via capistrano roles
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "capistrano-sidekiq-scheduler-roles", git: "https://github.com/umbrellio/capistrano-sidekiq-scheduler-roles.git"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Add this to your `Capfile`:
18
+
19
+ ```ruby
20
+ require "capistrano/sidekiq"
21
+ require "capistrano/sidekiq-scheduler-roles"
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ In your `sidekiq.yml` specify jobs with it's roles:
27
+ ```
28
+ :schedule:
29
+ JobForAllRoles:
30
+ every: 1s
31
+
32
+ JobForAppRole:
33
+ every: 1m
34
+ roles: [app]
35
+
36
+ JobForAppOrDBRoles:
37
+ every: 1h
38
+ roles: [app, db]
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/capistrano-sidekiq-scheduler-roles
44
+
45
+ ## License
46
+ Released under MIT License.
47
+
48
+ ## Authors
49
+ Created by Yakimov Pavel.
50
+
51
+ <a href="https://github.com/umbrellio/">
52
+ <img style="float: left;" src="https://umbrellio.github.io/Umbrellio/supported_by_umbrellio.svg" alt="Supported by Umbrellio" width="439" height="72">
53
+ </a>
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-sidekiq-scheduler-roles'
8
+ spec.version = '0.1.0'
9
+ spec.authors = ['past-one']
10
+ spec.email = ['mrpast@live.com']
11
+
12
+ spec.summary = 'A gem for configuring sidekiq-scheduler via capistrano roles.'
13
+ spec.description = 'capistrano-sidekiq-scheduler-roles is a gem ' \
14
+ 'for configuring sidekiq-scheduler via capistrano roles.'
15
+ spec.homepage = 'https://github.com/umbrellio/capistrano-sidekiq-scheduler-roles'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'capistrano'
22
+ spec.add_dependency 'capistrano-sidekiq'
23
+ spec.add_dependency 'sshkit'
24
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path('../tasks/sidekiq-scheduler-roles.rake', __FILE__)
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ set :sidekiq_config, -> { release_path.join('config', 'sidekiq.processed.yml') }
6
+
7
+ namespace :sidekiq_scheduler_roles do
8
+ task :prepare do
9
+ on roles(:all) do |host|
10
+ host_roles = host.roles_array.map(&:to_s)
11
+
12
+ config_path = fetch(:sidekiq_path, release_path).join('config', 'sidekiq.yml')
13
+
14
+ sidekiq_config = YAML.load(capture(:cat, config_path))
15
+
16
+ schedule = sidekiq_config[:schedule]
17
+ return unless schedule
18
+
19
+ schedule.each_key do |key|
20
+ roles = schedule[key].delete('roles')
21
+
22
+ next if !roles.is_a?(Array) || roles.empty?
23
+
24
+ schedule.delete(key) if (roles & host_roles).empty?
25
+ end
26
+
27
+ dump = YAML.dump(sidekiq_config).gsub("'", "\\'")
28
+
29
+ execute(:echo, "'#{dump}'", :>, fetch(:sidekiq_config))
30
+ end
31
+ end
32
+ end
33
+
34
+ before 'sidekiq:start', 'sidekiq_scheduler_roles:prepare'
35
+ before 'sidekiq:restart', 'sidekiq_scheduler_roles:prepare'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-sidekiq-scheduler-roles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - past-one
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capistrano-sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sshkit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: capistrano-sidekiq-scheduler-roles is a gem for configuring sidekiq-scheduler
56
+ via capistrano roles.
57
+ email:
58
+ - mrpast@live.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - capistrano-sidekiq-scheduler-roles.gemspec
69
+ - lib/capistrano-sidekiq-scheduler-roles.rb
70
+ - lib/capistrano/sidekiq-scheduler-roles.rb
71
+ - lib/capistrano/tasks/sidekiq-scheduler-roles.rake
72
+ homepage: https://github.com/umbrellio/capistrano-sidekiq-scheduler-roles
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.7.6
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: A gem for configuring sidekiq-scheduler via capistrano roles.
96
+ test_files: []