judoscale-resque 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: 7deeebf5eec99c390e3c8ca7f5bde2c1738e00df21c94859c7f01f92a3a8d8bc
4
+ data.tar.gz: e71578e2cc7d72ef2044c1e97005fb7f0657afa2922a3c3f4023f400789b9d5f
5
+ SHA512:
6
+ metadata.gz: 28c1483091686e5ac07ea2fc6889463e6a05830831f3d8bd6457a01b31c8bfa4aa02c68008b18133427da04edab5b8c69e15511fc51bcd2a74f36b0186a9e23e
7
+ data.tar.gz: f1278a7258bdb73f760ec4b0611712457d7fecd66a73b452d93c0dd84aedfb3ffc16d737bda138a7112eca59628ab9dafd3ec2d6821dce72ea35fef961e63b3f
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.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: ../judoscale-ruby
3
+ specs:
4
+ judoscale-ruby (1.0.0.rc1)
5
+
6
+ PATH
7
+ remote: .
8
+ specs:
9
+ judoscale-resque (1.0.0.rc1)
10
+ judoscale-ruby
11
+ resque (>= 2.0)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ minitest (5.15.0)
17
+ mono_logger (1.1.1)
18
+ multi_json (1.15.0)
19
+ mustermann (1.1.1)
20
+ ruby2_keywords (~> 0.0.1)
21
+ rack (2.2.3)
22
+ rack-protection (2.2.0)
23
+ rack
24
+ rake (13.0.6)
25
+ redis (4.6.0)
26
+ redis-namespace (1.8.2)
27
+ redis (>= 3.0.4)
28
+ resque (2.2.1)
29
+ mono_logger (~> 1.0)
30
+ multi_json (~> 1.0)
31
+ redis-namespace (~> 1.6)
32
+ sinatra (>= 0.9.2)
33
+ ruby2_keywords (0.0.5)
34
+ sinatra (2.2.0)
35
+ mustermann (~> 1.0)
36
+ rack (~> 2.2)
37
+ rack-protection (= 2.2.0)
38
+ tilt (~> 2.0)
39
+ tilt (2.0.10)
40
+
41
+ PLATFORMS
42
+ arm64-darwin-20
43
+ arm64-darwin-21
44
+ x86_64-darwin-21
45
+ x86_64-linux
46
+
47
+ DEPENDENCIES
48
+ judoscale-resque!
49
+ judoscale-ruby!
50
+ minitest
51
+ rake
52
+
53
+ BUNDLED WITH
54
+ 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/resque/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "judoscale-resque"
7
+ spec.version = Judoscale::Resque::VERSION
8
+ spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
9
+ spec.email = ["adam@adamlogic.com"]
10
+
11
+ spec.summary = "This gem provides Resque 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 "resque", ">= 2.0"
30
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/job_metrics_collector"
4
+ require "judoscale/metric"
5
+
6
+ module Judoscale
7
+ module Resque
8
+ class MetricsCollector < Judoscale::JobMetricsCollector
9
+ def self.adapter_identifier
10
+ :resque
11
+ end
12
+
13
+ def collect
14
+ metrics = []
15
+ current_queues = ::Resque.queues
16
+
17
+ if track_busy_jobs?
18
+ busy_counts = Hash.new { |h, k| h[k] = 0 }
19
+
20
+ ::Resque.working.each do |worker|
21
+ if !worker.idle? && (job = worker.job)
22
+ busy_counts[job["queue"]] += 1
23
+ end
24
+ end
25
+ end
26
+
27
+ self.queues |= current_queues
28
+
29
+ queues.each do |queue|
30
+ next if queue.nil? || queue.empty?
31
+ depth = ::Resque.size(queue)
32
+ metrics.push Metric.new(:qd, depth, Time.now, queue)
33
+
34
+ if track_busy_jobs?
35
+ busy_count = busy_counts[queue]
36
+ metrics.push Metric.new(:busy, busy_count, Time.now, queue)
37
+ end
38
+ end
39
+
40
+ log_collection(metrics)
41
+ metrics
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Judoscale
4
+ module Resque
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/resque/version"
6
+ require "judoscale/resque/metrics_collector"
7
+ require "resque"
8
+
9
+ Judoscale.add_adapter :"judoscale-resque", {
10
+ adapter_version: Judoscale::Resque::VERSION,
11
+ framework_version: ::Resque::VERSION
12
+ }, metrics_collector: Judoscale::Resque::MetricsCollector
13
+
14
+ Judoscale::Config.add_adapter_config :resque, Judoscale::Config::JobAdapterConfig
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "judoscale/resque"
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: judoscale-resque
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: resque
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '2.0'
42
+ description:
43
+ email:
44
+ - adam@adamlogic.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - Rakefile
52
+ - judoscale-resque.gemspec
53
+ - lib/judoscale-resque.rb
54
+ - lib/judoscale/resque.rb
55
+ - lib/judoscale/resque/metrics_collector.rb
56
+ - lib/judoscale/resque/version.rb
57
+ homepage: https://judoscale.com
58
+ licenses:
59
+ - MIT
60
+ metadata:
61
+ homepage_uri: https://judoscale.com
62
+ bug_tracker_uri: https://github.com/judoscale/judoscale-ruby/issues
63
+ documentation_uri: https://judoscale.com/docs
64
+ changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
65
+ source_code_uri: https://github.com/judoscale/judoscale-ruby
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.6.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">"
78
+ - !ruby/object:Gem::Version
79
+ version: 1.3.1
80
+ requirements: []
81
+ rubygems_version: 3.2.32
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: This gem provides Resque integration with the Judoscale autoscaling add-on
85
+ for Heroku.
86
+ test_files: []