judoscale-sidekiq 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1989caee2cc945b2331ee3afcd12db7acf48244dd62f2d4bf625b234a7ed3f57
4
+ data.tar.gz: 5ca9471e467c3f22103d33e7332c9cbed89603a72abe605f91f7a52b264c5a97
5
+ SHA512:
6
+ metadata.gz: 3a8a5c8ccb16cf3a121628f71bda7a3684bd3a6fff010182d3984537a51ecb785784ac49030cce6afb48844bd97e129764f63f3a9b0b131706edca825e956d8c
7
+ data.tar.gz: 0f81f1ca695c776f8e5dadba021c8d4d304bada687db2cdff77ca5c2864ceb51fa8639b5280b489ef7a5e388c22241217feb19800698d8983c2c8de1b49a1850
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "judoscale-ruby", path: "../judoscale-ruby"
6
+ gem "minitest"
7
+ gem "rake"
data/Gemfile-sidekiq-5 ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "judoscale-ruby", path: "../judoscale-ruby"
6
+ gem "sidekiq", "~> 5.0"
7
+ gem "minitest"
8
+ gem "rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: ../judoscale-ruby
3
+ specs:
4
+ judoscale-ruby (1.0.0.rc1)
5
+
6
+ PATH
7
+ remote: .
8
+ specs:
9
+ judoscale-sidekiq (1.0.0.rc1)
10
+ judoscale-ruby
11
+ sidekiq (>= 5.0)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ connection_pool (2.2.5)
17
+ minitest (5.15.0)
18
+ rack (2.2.3)
19
+ rake (13.0.6)
20
+ redis (4.6.0)
21
+ sidekiq (6.4.1)
22
+ connection_pool (>= 2.2.2)
23
+ rack (~> 2.0)
24
+ redis (>= 4.2.0)
25
+
26
+ PLATFORMS
27
+ arm64-darwin-20
28
+ arm64-darwin-21
29
+ x86_64-darwin-21
30
+ x86_64-linux
31
+
32
+ DEPENDENCIES
33
+ judoscale-ruby!
34
+ judoscale-sidekiq!
35
+ minitest
36
+ rake
37
+
38
+ BUNDLED WITH
39
+ 2.3.9
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "lib"
8
+ t.libs << "test"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "judoscale/sidekiq/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "judoscale-sidekiq"
7
+ spec.version = Judoscale::Sidekiq::VERSION
8
+ spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
9
+ spec.email = ["adam@adamlogic.com"]
10
+
11
+ spec.summary = "This gem provides Sidekiq integration with the Judoscale autoscaling add-on for Heroku."
12
+ spec.homepage = "https://judoscale.com"
13
+ spec.license = "MIT"
14
+
15
+ spec.metadata = {
16
+ "homepage_uri" => "https://judoscale.com",
17
+ "bug_tracker_uri" => "https://github.com/judoscale/judoscale-ruby/issues",
18
+ "documentation_uri" => "https://judoscale.com/docs",
19
+ "changelog_uri" => "https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md",
20
+ "source_code_uri" => "https://github.com/judoscale/judoscale-ruby"
21
+ }
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.required_ruby_version = ">= 2.6.0"
27
+
28
+ spec.add_dependency "judoscale-ruby"
29
+ spec.add_dependency "sidekiq", ">= 5.0"
30
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/job_metrics_collector"
4
+ require "judoscale/metric"
5
+
6
+ module Judoscale
7
+ module Sidekiq
8
+ class MetricsCollector < Judoscale::JobMetricsCollector
9
+ def self.adapter_identifier
10
+ :sidekiq
11
+ end
12
+
13
+ def collect
14
+ metrics = []
15
+ queues_by_name = ::Sidekiq::Queue.all.each_with_object({}) do |queue, obj|
16
+ obj[queue.name] = queue
17
+ end
18
+
19
+ self.queues |= queues_by_name.keys
20
+
21
+ if track_busy_jobs?
22
+ busy_counts = Hash.new { |h, k| h[k] = 0 }
23
+ ::Sidekiq::Workers.new.each do |pid, tid, work|
24
+ busy_counts[work.dig("payload", "queue")] += 1
25
+ end
26
+ end
27
+
28
+ queues.each do |queue_name|
29
+ queue = queues_by_name.fetch(queue_name) { |name| ::Sidekiq::Queue.new(name) }
30
+ latency_ms = (queue.latency * 1000).ceil
31
+ depth = queue.size
32
+
33
+ metrics.push Metric.new(:qt, latency_ms, Time.now, queue_name)
34
+ metrics.push Metric.new(:qd, depth, Time.now, queue_name)
35
+
36
+ if track_busy_jobs?
37
+ busy_count = busy_counts[queue_name]
38
+ metrics.push Metric.new(:busy, busy_count, Time.now, queue_name)
39
+ end
40
+ end
41
+
42
+ log_collection(metrics)
43
+ metrics
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Judoscale
4
+ module Sidekiq
5
+ VERSION = "1.0.0.rc1"
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale-ruby"
4
+ require "judoscale/config"
5
+ require "judoscale/sidekiq/version"
6
+ require "judoscale/sidekiq/metrics_collector"
7
+ require "sidekiq/api"
8
+
9
+ Judoscale.add_adapter :"judoscale-sidekiq", {
10
+ adapter_version: Judoscale::Sidekiq::VERSION,
11
+ framework_version: ::Sidekiq::VERSION
12
+ }, metrics_collector: Judoscale::Sidekiq::MetricsCollector
13
+
14
+ Judoscale::Config.add_adapter_config :sidekiq, Judoscale::Config::JobAdapterConfig
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/sidekiq"
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: judoscale-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Adam McCrea
8
+ - Carlos Antonio da Silva
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-04-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: judoscale-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: sidekiq
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '5.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '5.0'
42
+ description:
43
+ email:
44
+ - adam@adamlogic.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile
50
+ - Gemfile-sidekiq-5
51
+ - Gemfile.lock
52
+ - Rakefile
53
+ - judoscale-sidekiq.gemspec
54
+ - lib/judoscale-sidekiq.rb
55
+ - lib/judoscale/sidekiq.rb
56
+ - lib/judoscale/sidekiq/metrics_collector.rb
57
+ - lib/judoscale/sidekiq/version.rb
58
+ homepage: https://judoscale.com
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://judoscale.com
63
+ bug_tracker_uri: https://github.com/judoscale/judoscale-ruby/issues
64
+ documentation_uri: https://judoscale.com/docs
65
+ changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
66
+ source_code_uri: https://github.com/judoscale/judoscale-ruby
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.6.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">"
79
+ - !ruby/object:Gem::Version
80
+ version: 1.3.1
81
+ requirements: []
82
+ rubygems_version: 3.2.32
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: This gem provides Sidekiq integration with the Judoscale autoscaling add-on
86
+ for Heroku.
87
+ test_files: []