rails-autoscale-solid_queue 1.6.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: 810865e372910f93b1928a0d7a38cc54903b42bd0137242d1c2db4a267d1b48b
4
+ data.tar.gz: 31dd78538f4e3d5c73f1764c4574f32d5893d28dbdc33ea873077f799b650095
5
+ SHA512:
6
+ metadata.gz: af8d5ee5e5072c33330f69d19cea3c4bb7deb217f4e250972b8a26e2bdd7b48b68ec024f42d6853d37fd22e3b75bc58e493fa6dfe540f08c2fec19966fdb1d2c
7
+ data.tar.gz: cbdd94a183b975f94bfa639efc3252511d81d1aa8b343a8779faf0e385c28a0140f9d5e5d39006c69d270c5ccca84b741b2f876732ca3b15e85693ff9fb3cc1f
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec name: "judoscale-solid_queue"
4
+
5
+ gem "judoscale-ruby", path: "../judoscale-ruby"
6
+ gem "activerecord"
7
+ gem "pg"
8
+ gem "minitest"
9
+ gem "rake"
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "lib"
7
+ t.libs << "test"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ end
10
+
11
+ 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/solid_queue/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "judoscale-solid_queue"
7
+ spec.version = Judoscale::SolidQueue::VERSION
8
+ spec.authors = ["Adam McCrea", "Carlos Antonio da Silva", "Jon Sullivan"]
9
+ spec.email = ["hello@judoscale.com"]
10
+
11
+ spec.summary = "This gem provides SolidQueue 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.7.0"
27
+
28
+ spec.add_dependency "judoscale-ruby", Judoscale::SolidQueue::VERSION
29
+ spec.add_dependency "solid_queue", ">= 0.3"
30
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/job_metrics_collector"
4
+ require "judoscale/job_metrics_collector/active_record_helper"
5
+ require "judoscale/metric"
6
+
7
+ module Judoscale
8
+ module SolidQueue
9
+ class MetricsCollector < Judoscale::JobMetricsCollector
10
+ include ActiveRecordHelper
11
+
12
+ def self.adapter_config
13
+ Judoscale::Config.instance.solid_queue
14
+ end
15
+
16
+ def self.collect?(config)
17
+ super && ActiveRecordHelper.table_exists_for_model?(::SolidQueue::Job)
18
+ end
19
+
20
+ def initialize
21
+ super
22
+
23
+ queue_names = run_silently do
24
+ ::SolidQueue::Job.distinct.pluck(:queue_name)
25
+ end
26
+ self.queues |= queue_names
27
+ end
28
+
29
+ def collect
30
+ metrics = []
31
+ time = Time.now.utc
32
+
33
+ oldest_execution_time_by_queue = run_silently do
34
+ ::SolidQueue::ReadyExecution.group(:queue_name).minimum(:created_at)
35
+ end
36
+ self.queues |= oldest_execution_time_by_queue.keys
37
+
38
+ if track_busy_jobs?
39
+ busy_count_by_queue = run_silently do
40
+ ::SolidQueue::Job.joins(:claimed_execution).group(:queue_name).count
41
+ end
42
+ self.queues |= busy_count_by_queue.keys
43
+ end
44
+
45
+ queues.each do |queue|
46
+ run_at = oldest_execution_time_by_queue[queue]
47
+ latency_ms = run_at ? ((time - run_at) * 1000).ceil : 0
48
+ latency_ms = 0 if latency_ms < 0
49
+
50
+ metrics.push Metric.new(:qt, latency_ms, time, queue)
51
+
52
+ if track_busy_jobs?
53
+ busy_count = busy_count_by_queue[queue] || 0
54
+ metrics.push Metric.new(:busy, busy_count, Time.now, queue)
55
+ end
56
+ end
57
+
58
+ log_collection(metrics)
59
+ metrics
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Judoscale
4
+ module SolidQueue
5
+ VERSION = "1.6.0"
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "solid_queue"
4
+ require "judoscale-ruby"
5
+ require "judoscale/config"
6
+ require "judoscale/solid_queue/version"
7
+ require "judoscale/solid_queue/metrics_collector"
8
+
9
+ Judoscale.add_adapter :"judoscale-solid_queue",
10
+ {
11
+ adapter_version: Judoscale::SolidQueue::VERSION,
12
+ framework_version: ::SolidQueue::VERSION
13
+ },
14
+ metrics_collector: Judoscale::SolidQueue::MetricsCollector,
15
+ expose_config: Judoscale::Config::JobAdapterConfig.new(:solid_queue)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/solid_queue"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/solid_queue"
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "judoscale/solid_queue/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rails-autoscale-solid_queue"
7
+ spec.version = Judoscale::SolidQueue::VERSION
8
+ spec.authors = ["Adam McCrea", "Carlos Antonio da Silva", "Jon Sullivan"]
9
+ spec.email = ["hello@judoscale.com"]
10
+
11
+ spec.summary = "This gem provides SolidQueue 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.7.0"
27
+
28
+ spec.add_dependency "rails-autoscale-core", Judoscale::SolidQueue::VERSION
29
+ spec.add_dependency "solid_queue", ">= 0.3"
30
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-autoscale-solid_queue
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam McCrea
8
+ - Carlos Antonio da Silva
9
+ - Jon Sullivan
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2024-04-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails-autoscale-core
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.6.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: solid_queue
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0.3'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0.3'
43
+ description:
44
+ email:
45
+ - hello@judoscale.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - Gemfile
51
+ - Rakefile
52
+ - judoscale-solid_queue.gemspec
53
+ - lib/judoscale-solid_queue.rb
54
+ - lib/judoscale/solid_queue.rb
55
+ - lib/judoscale/solid_queue/metrics_collector.rb
56
+ - lib/judoscale/solid_queue/version.rb
57
+ - lib/rails-autoscale-solid_queue.rb
58
+ - rails-autoscale-solid_queue.gemspec
59
+ homepage: https://judoscale.com
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://judoscale.com
64
+ bug_tracker_uri: https://github.com/judoscale/judoscale-ruby/issues
65
+ documentation_uri: https://judoscale.com/docs
66
+ changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
67
+ source_code_uri: https://github.com/judoscale/judoscale-ruby
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 2.7.0
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.4.10
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: This gem provides SolidQueue integration with the Judoscale autoscaling add-on
87
+ for Heroku.
88
+ test_files: []