neetodeploy-autoscale 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b25708e10d77c473b33ff4f46b1537b0977bb18c990f54bdf33afc4b3a6947
4
- data.tar.gz: d2faea5f93812588a2850b5cf5e2bb84e5efbf3295331e7340f2153d43ec2841
3
+ metadata.gz: deb2f21200f7b5dabeb6b6b18834172c45b0ea61b6166d29fdde16d48566f93a
4
+ data.tar.gz: 4c3b13a11b9f6335e2979f5efcdf71b8b5f911d4a2367a99dee300fcbbae617e
5
5
  SHA512:
6
- metadata.gz: a732fd7615496308c4e10da3b73dfbdf82e0713d906719e618e9a07fc1611a279b12186ff232b467ae2c42663dc4314b592c848810acc3882af006806bce3220
7
- data.tar.gz: b9b4ee9cbb20796597ca64dfd4c0d621c2f88b66655544c3e0f376c3e0defd71b261f489f3ccd90ddbdd087e3059bed8147d96ee84e3a0edf6e5f539b039efdf
6
+ metadata.gz: 5122fc863b9758419ad19f4c8d728c1fbdd8ba669e46f487d140bffad9478f107cf0e957879158d5a9c95119b09ccb262108eaca0501aadd3c47f560d9daa1fd
7
+ data.tar.gz: ecd6dd377cd1c489b618c7f6b24d3361643f6d27c8640b134530195cbb5fc1a548915ced79ab00371ef1a6d0c7b908453c44474d9683636a0ae7cc3aff29ab0b
@@ -8,15 +8,22 @@ module Neetodeploy
8
8
  def call(worker, job, queue)
9
9
  url = URI.parse("https://nd-queue-time-exporter.neetodeployapp.com/metrics")
10
10
 
11
- query_params = URI.encode_www_form(app_name: ENV.to_h["NEETODEPLOY_APP_NAME"], process_type: "worker", queue_time: queue_time(worker, job, queue))
11
+ queues_by_name = ::Sidekiq::Queue.all.each_with_object({}) do |queue_name, obj|
12
+ obj[queue_name.name] = queue_name
13
+ end
12
14
 
13
- url.query = query_params
15
+ queues = queues_by_name.keys
14
16
 
15
- post = Net::HTTP::Post.new(url)
16
- post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy"
17
+ queues.each do |queue_name|
18
+ queue = queues_by_name.fetch(queue_name) { |name| ::Sidekiq::Queue.new(name) }
17
19
 
18
- Net::HTTP.start(url.host, url.port, use_ssl: false) do |http|
19
- http.request(post)
20
+ query_params = URI.encode_www_form(app_name: ENV.to_h["NEETODEPLOY_APP_NAME"], process_type: "worker", queue_name: queue_name, queue_time: queue_time(queue))
21
+ url.query = query_params
22
+ post = Net::HTTP::Post.new(url)
23
+ post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy"
24
+ Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
25
+ http.request(post)
26
+ end
20
27
  end
21
28
 
22
29
  yield
@@ -24,8 +31,14 @@ module Neetodeploy
24
31
 
25
32
  private
26
33
 
27
- def queue_time(worker, job, queue)
28
- (Time.now - Time.at(job["created_at"])) * 1000
34
+ def queues
35
+ ::Sidekiq::Queue.all
36
+ end
37
+
38
+ def queue_time(queue_name)
39
+ queue = ::Sidekiq::Queue.new(queue_name)
40
+
41
+ (queue.latency * 1000).ceil
29
42
  end
30
43
  end
31
44
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neetodeploy
4
4
  module Autoscale
5
- VERSION = "0.6.0"
5
+ VERSION = "0.8.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neetodeploy-autoscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sreeram Venkitesh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-13 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: For automatically scaling your Rails application based on network metrics
14
14
  email: