rails-autoscale-sidekiq 1.0.0

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: 8e9684c555428870f2a5a4ea0b68007c662fa76d36dae33354cb9ef72933ca58
4
+ data.tar.gz: c3166410d4ab6776cabdc8d5b3312ce5072fb5308a39f4a2edf98a2367d09e63
5
+ SHA512:
6
+ metadata.gz: 190bb47db5e985c135049884a74c9279d4dda15e3e706febb89fe040662f208ace82c38747d8e81729dff94627be85390d1d8ee1ad1b7030abcb07b815158c1e
7
+ data.tar.gz: 86f8a21e283ba19b613610211619e20fd44ae4fbcd87623b0c0a733519d139351278db956c7acbe82de97328c11cbad95b44fdcd2d1daaa6579d44861bda99a4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rails-autoscale-core", path: "../rails-autoscale-core"
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 "rails-autoscale-core", path: "../rails-autoscale-core"
6
+ gem "sidekiq", "~> 5.0"
7
+ gem "minitest"
8
+ gem "rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: ../rails-autoscale-core
3
+ specs:
4
+ rails-autoscale-core (1.0.0)
5
+
6
+ PATH
7
+ remote: .
8
+ specs:
9
+ rails-autoscale-sidekiq (1.0.0)
10
+ rails-autoscale-core
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.4)
19
+ rake (13.0.6)
20
+ redis (4.7.1)
21
+ sidekiq (6.5.4)
22
+ connection_pool (>= 2.2.2)
23
+ rack (~> 2.0)
24
+ redis (>= 4.5.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
+ minitest
34
+ rails-autoscale-core!
35
+ rails-autoscale-sidekiq!
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,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_autoscale/sidekiq"
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_autoscale/job_metrics_collector"
4
+ require "rails_autoscale/metric"
5
+
6
+ module RailsAutoscale
7
+ module Sidekiq
8
+ class MetricsCollector < RailsAutoscale::JobMetricsCollector
9
+ def self.adapter_config
10
+ RailsAutoscale::Config.instance.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 RailsAutoscale
4
+ module Sidekiq
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails-autoscale-core"
4
+ require "rails_autoscale/config"
5
+ require "rails_autoscale/sidekiq/version"
6
+ require "rails_autoscale/sidekiq/metrics_collector"
7
+ require "sidekiq/api"
8
+
9
+ RailsAutoscale.add_adapter :"rails-autoscale-sidekiq",
10
+ {
11
+ adapter_version: RailsAutoscale::Sidekiq::VERSION,
12
+ framework_version: ::Sidekiq::VERSION
13
+ },
14
+ metrics_collector: RailsAutoscale::Sidekiq::MetricsCollector,
15
+ expose_config: RailsAutoscale::Config::JobAdapterConfig.new(:sidekiq)
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "rails_autoscale/sidekiq/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rails-autoscale-sidekiq"
7
+ spec.version = RailsAutoscale::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 Rails Autoscale autoscaling add-on for Heroku."
12
+ spec.homepage = "https://railsautoscale.com"
13
+ spec.license = "MIT"
14
+
15
+ spec.metadata = {
16
+ "homepage_uri" => "https://railsautoscale.com",
17
+ "bug_tracker_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems/issues",
18
+ "documentation_uri" => "https://railsautoscale.com/docs",
19
+ "changelog_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems/blob/main/CHANGELOG.md",
20
+ "source_code_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems"
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 "rails-autoscale-core"
29
+ spec.add_dependency "sidekiq", ">= 5.0"
30
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-autoscale-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam McCrea
8
+ - Carlos Antonio da Silva
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-09-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails-autoscale-core
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
+ - lib/rails-autoscale-sidekiq.rb
54
+ - lib/rails_autoscale/sidekiq.rb
55
+ - lib/rails_autoscale/sidekiq/metrics_collector.rb
56
+ - lib/rails_autoscale/sidekiq/version.rb
57
+ - rails-autoscale-sidekiq.gemspec
58
+ homepage: https://railsautoscale.com
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://railsautoscale.com
63
+ bug_tracker_uri: https://github.com/rails-autoscale/rails-autoscale-gems/issues
64
+ documentation_uri: https://railsautoscale.com/docs
65
+ changelog_uri: https://github.com/rails-autoscale/rails-autoscale-gems/blob/main/CHANGELOG.md
66
+ source_code_uri: https://github.com/rails-autoscale/rails-autoscale-gems
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: '0'
81
+ requirements: []
82
+ rubygems_version: 3.2.32
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: This gem provides Sidekiq integration with the Rails Autoscale autoscaling
86
+ add-on for Heroku.
87
+ test_files: []