neetodeploy-autoscale 0.7.0 → 0.9.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: ae89d71a8dc745af2e4af2c94a94c16497a2067ec5fbc31e1ad351f5f84bd333
4
- data.tar.gz: 69e44e72990b27b8ea1e6c9398f74af6b7c73d8dfb5dc0bc3c0995821da8c16a
3
+ metadata.gz: 5913f148d9a61709274f497c7af3fc51155bbf5bee2e3d7a875e26176b1210bb
4
+ data.tar.gz: 43abafd353ded35fcd89ba38c29cd3b892ac240470577b088b7d4210dc673eef
5
5
  SHA512:
6
- metadata.gz: fc14913a507e277fb7e76a5917053e7a7a2cc4039a3180e5cb5625b3807f23c72c244e0a60774a24c26d35ffae3834c4bff4d3a2fc264e19006b49308b741112
7
- data.tar.gz: af10749f4ab0e928fe3564c9ee86fb4933bace261e7d3a8e59a4032e596a557f88506dca517c7852790b758ef7b808d8abd6ae2d06083cc7deb72ada008b5885
6
+ metadata.gz: 6955cc1a81aff7b522e0c59362e6dc286f8b3a3d0fe77d836d4f4d479715fd6b8eef8356ae459610922182f4f6d4ec107c96c190fd18e62903b625a225e3917b
7
+ data.tar.gz: 0b85b705c7d514f7cb1775c8f3aadb9f4a43031fc2804cf4af88c50007f313a218a120722db59ac1275b81cb6e154ff10b697fb25e8626c02f6f25f08d0ee525
@@ -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_obj|
18
+ queue = queues_by_name.fetch(queue_obj) { |name| ::Sidekiq::Queue.new(name) }
17
19
 
18
- Net::HTTP.start(url.host, url.port, use_ssl: true) 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_obj: queue_obj, 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_obj)
39
+ queue = ::Sidekiq::Queue.new(queue_obj.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.7.0"
5
+ VERSION = "0.9.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.7.0
4
+ version: 0.9.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-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: For automatically scaling your Rails application based on network metrics
14
14
  email: