judoscale-delayed_job 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile-activerecord-6-1 +9 -0
- data/Gemfile.lock +55 -0
- data/Rakefile +12 -0
- data/judoscale-delayed_job.gemspec +30 -0
- data/lib/judoscale/delayed_job/metrics_collector.rb +65 -0
- data/lib/judoscale/delayed_job/version.rb +7 -0
- data/lib/judoscale/delayed_job.rb +14 -0
- data/lib/judoscale-delayed_job.rb +3 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09ff7aa09e479cf943cbac1afb970042506ef43c4b9d2fba6864d4f1fdcd0629'
|
4
|
+
data.tar.gz: 412d65114dbbbe4a16431b553fb1013b7952ac20b47ad5d357bec42aaff8744c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df3c96b26fc811317752d446bb74f383ee377237885a2983a3d1a257df109acd785be77c713277bff5c1090e486c5373d5f647c2b6cc1e74fb8b5e36a306dddc
|
7
|
+
data.tar.gz: 996a78ec9f098fab90be6c347aa625f4e05b2a2720fc272d946c2eab088044158778979afad1d22a8911f214ffa02967817ee8a0a01f21fb3384b0062abd91fc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../judoscale-ruby
|
3
|
+
specs:
|
4
|
+
judoscale-ruby (1.0.0.rc1)
|
5
|
+
|
6
|
+
PATH
|
7
|
+
remote: .
|
8
|
+
specs:
|
9
|
+
judoscale-delayed_job (1.0.0.rc1)
|
10
|
+
delayed_job_active_record (>= 4.0)
|
11
|
+
judoscale-ruby
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
activemodel (7.0.2.3)
|
17
|
+
activesupport (= 7.0.2.3)
|
18
|
+
activerecord (7.0.2.3)
|
19
|
+
activemodel (= 7.0.2.3)
|
20
|
+
activesupport (= 7.0.2.3)
|
21
|
+
activesupport (7.0.2.3)
|
22
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
minitest (>= 5.1)
|
25
|
+
tzinfo (~> 2.0)
|
26
|
+
concurrent-ruby (1.1.10)
|
27
|
+
delayed_job (4.1.10)
|
28
|
+
activesupport (>= 3.0, < 8.0)
|
29
|
+
delayed_job_active_record (4.1.7)
|
30
|
+
activerecord (>= 3.0, < 8.0)
|
31
|
+
delayed_job (>= 3.0, < 5)
|
32
|
+
i18n (1.10.0)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
minitest (5.15.0)
|
35
|
+
pg (1.3.5)
|
36
|
+
rake (13.0.6)
|
37
|
+
tzinfo (2.0.4)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
arm64-darwin-20
|
42
|
+
arm64-darwin-21
|
43
|
+
x86_64-darwin-21
|
44
|
+
x86_64-linux
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
activerecord
|
48
|
+
judoscale-delayed_job!
|
49
|
+
judoscale-ruby!
|
50
|
+
minitest
|
51
|
+
pg
|
52
|
+
rake
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
2.3.9
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "judoscale/delayed_job/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "judoscale-delayed_job"
|
7
|
+
spec.version = Judoscale::DelayedJob::VERSION
|
8
|
+
spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
|
9
|
+
spec.email = ["adam@adamlogic.com"]
|
10
|
+
|
11
|
+
spec.summary = "This gem provides DelayedJob 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 "delayed_job_active_record", ">= 4.0"
|
30
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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 DelayedJob
|
9
|
+
class MetricsCollector < Judoscale::JobMetricsCollector
|
10
|
+
include ActiveRecordHelper
|
11
|
+
|
12
|
+
METRICS_SQL = ActiveRecordHelper.cleanse_sql(<<~SQL)
|
13
|
+
SELECT COALESCE(queue, 'default'), min(run_at)
|
14
|
+
FROM delayed_jobs
|
15
|
+
WHERE locked_at IS NULL
|
16
|
+
AND failed_at IS NULL
|
17
|
+
GROUP BY queue
|
18
|
+
SQL
|
19
|
+
|
20
|
+
BUSY_METRICS_SQL = ActiveRecordHelper.cleanse_sql(<<~SQL)
|
21
|
+
SELECT COALESCE(queue, 'default'), count(*)
|
22
|
+
FROM delayed_jobs
|
23
|
+
WHERE locked_at IS NOT NULL
|
24
|
+
AND locked_by IS NOT NULL
|
25
|
+
AND failed_at IS NULL
|
26
|
+
GROUP BY 1
|
27
|
+
SQL
|
28
|
+
|
29
|
+
def self.adapter_identifier
|
30
|
+
:delayed_job
|
31
|
+
end
|
32
|
+
|
33
|
+
def collect
|
34
|
+
metrics = []
|
35
|
+
t = Time.now.utc
|
36
|
+
|
37
|
+
run_at_by_queue = select_rows_silently(METRICS_SQL).to_h
|
38
|
+
self.queues |= run_at_by_queue.keys
|
39
|
+
|
40
|
+
if track_busy_jobs?
|
41
|
+
busy_count_by_queue = select_rows_silently(BUSY_METRICS_SQL).to_h
|
42
|
+
self.queues |= busy_count_by_queue.keys
|
43
|
+
end
|
44
|
+
|
45
|
+
queues.each do |queue|
|
46
|
+
run_at = run_at_by_queue[queue]
|
47
|
+
# DateTime.parse assumes a UTC string
|
48
|
+
run_at = DateTime.parse(run_at) if run_at.is_a?(String)
|
49
|
+
latency_ms = run_at ? ((t - run_at) * 1000).ceil : 0
|
50
|
+
latency_ms = 0 if latency_ms < 0
|
51
|
+
|
52
|
+
metrics.push Metric.new(:qt, latency_ms, t, queue)
|
53
|
+
|
54
|
+
if track_busy_jobs?
|
55
|
+
busy_count = busy_count_by_queue[queue] || 0
|
56
|
+
metrics.push Metric.new(:busy, busy_count, Time.now, queue)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
log_collection(metrics)
|
61
|
+
metrics
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "judoscale-ruby"
|
4
|
+
require "judoscale/config"
|
5
|
+
require "judoscale/delayed_job/version"
|
6
|
+
require "judoscale/delayed_job/metrics_collector"
|
7
|
+
require "delayed_job_active_record"
|
8
|
+
|
9
|
+
Judoscale.add_adapter :"judoscale-delayed_job", {
|
10
|
+
adapter_version: Judoscale::DelayedJob::VERSION,
|
11
|
+
framework_version: Gem.loaded_specs["delayed_job_active_record"].version.to_s # DJ doesn't have a `VERSION` constant
|
12
|
+
}, metrics_collector: Judoscale::DelayedJob::MetricsCollector
|
13
|
+
|
14
|
+
Judoscale::Config.add_adapter_config :delayed_job, Judoscale::Config::JobAdapterConfig
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: judoscale-delayed_job
|
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: delayed_job_active_record
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '4.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '4.0'
|
42
|
+
description:
|
43
|
+
email:
|
44
|
+
- adam@adamlogic.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile-activerecord-6-1
|
51
|
+
- Gemfile.lock
|
52
|
+
- Rakefile
|
53
|
+
- judoscale-delayed_job.gemspec
|
54
|
+
- lib/judoscale-delayed_job.rb
|
55
|
+
- lib/judoscale/delayed_job.rb
|
56
|
+
- lib/judoscale/delayed_job/metrics_collector.rb
|
57
|
+
- lib/judoscale/delayed_job/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 DelayedJob integration with the Judoscale autoscaling add-on
|
86
|
+
for Heroku.
|
87
|
+
test_files: []
|