auto_scale_workers 0.4.2 → 0.4.3

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: 8397cb76e124269a32c9fc0bdc73fe16d6ccf7a1d79044bcaddff03a09e8ec94
4
- data.tar.gz: c49a595ac53152c5acd26e43f53d85e8e6b648e774727bc2b909a7649c7f433d
3
+ metadata.gz: eb5294640d6aa9edbef12b2b3e477cda9903fb4eb39d0f4f630314dae4145ecf
4
+ data.tar.gz: 61437c8b14d0237cda4af289517cf60017e2aabd437df59a472922f97e2eeebe
5
5
  SHA512:
6
- metadata.gz: '019009c5aa9b10463f65f99a647b4616c1d74bae36e7bd883750f063a86031c3cf7c4d338bbfe1aab3f7bd889dc857e47115e50f27afd540970af17650654c7b'
7
- data.tar.gz: 80d60724a41621e907d8e62ab93283c0b4e34349f5d5ca63a011908692c1ce3ac1e1ede7fafc6810123271f0682d545ceaa74131dfa130e166bfb9389a56b294
6
+ metadata.gz: da94a1419740f84a2581f5556a613b724c2f0bcc4f358c9c829caec3dcb703e30b8103c15733ee56da5a2f03972530388668cc27d5dab75d5e5f16d25455dc23
7
+ data.tar.gz: a94465256d6532a53fc5a4fa14c125151c5d7a8cbad5f0b9b620821c1ee59f18658ab0e5a5eccf759c491a90d86a63084d5b2e68b8f64ee0a3f3d0957afbbf6f
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/mcfox/auto_scale_workers"
20
+ spec.metadata["source_code_uri"] = "https://github.com/mcfox/auto_scale_workers_rails"
21
21
  spec.metadata["changelog_uri"] = "https://github.com/mcfox/auto_scale_workers/blob/main/CHANGELOG.md"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
@@ -1,26 +1,39 @@
1
- require 'httparty'
2
- require 'concurrent'
3
- require 'sidekiq'
4
- require 'auto_scale_workers/sidekiq_collector'
1
+ require "httparty"
2
+ require "concurrent"
3
+ require "sidekiq"
4
+ require "auto_scale_workers/sidekiq_collector"
5
5
 
6
6
  module AutoScaleWorkers
7
+
8
+ @config = {
9
+ api_url: "https://api.autoscaleworkers.com/collect_data"
10
+ }
11
+
12
+ def self.configs
13
+ yield(@config)
14
+ end
15
+
16
+ def self.config
17
+ @config
18
+ end
19
+
7
20
  class Collector
8
- def self.start(interval, queues=[])
21
+ def self.start(interval, queues = [])
22
+ puts "Stating Collector"
9
23
  Concurrent::TimerTask.new(execution_interval: interval) do
10
24
  # Chame sua API aqui
11
- puts "Chamando API..."
12
- payload = SidekiqCollector.get_stat(queues)
13
- response = HTTParty.post("httgp://api.autoscaleworkers.com/collect_data",
14
- body: payload,
15
- headers: { 'Content-Type' => 'application/json' })
25
+ token = AutoScaleWorkers.config[:token]
26
+ api_url = AutoScaleWorkers.config[:api_url]
27
+ body = SidekiqCollector.get_stat(queues).to_json
28
+ response = HTTParty.post(api_url, body: body, headers: { 'Content-Type' => 'application/json' })
16
29
  if response.success?
17
- puts "Requisição bem-sucedida!"
18
- # Faça algo com response.body ou response.parsed_response, se necessário
30
+ puts "Posted do ASW"
19
31
  else
20
- puts "Erro na requisição: #{response.code}"
21
- # Trate o erro conforme necessário
32
+ raise "Erro na requisição: #{response.code}"
22
33
  end
23
34
  end.execute
35
+ rescue StandardError => e
36
+ puts "Erro: #{e.message}"
24
37
  end
25
38
  end
26
39
  end
@@ -6,11 +6,9 @@ module AutoScaleWorkers
6
6
  queues = Sidekiq::Queue.all if queues.empty?
7
7
  payload = {}
8
8
  queues.each do |queue|
9
- payload[queue.name] << { size: queue.size,
10
- enqueued: queue.enqueued,
11
- latency: queue.latency,
12
- paused: queue.paused?
13
- }
9
+ payload[queue.name] = { size: queue.size,
10
+ latency: queue.latency,
11
+ paused: queue.paused? }
14
12
  end
15
13
  payload['stats'] = Sidekiq::Stats.new.fetch_stats_fast!
16
14
  payload
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AutoScaleWorkers
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "auto_scale_workers/version"
4
- require_relative "auto_scale_workers/api_worker"
4
+ require_relative "auto_scale_workers/collector"
5
5
  module AutoScaleWorkers
6
6
  class Error < StandardError; end
7
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_scale_workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - joseneto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-31 00:00:00.000000000 Z
11
+ date: 2024-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -80,7 +80,7 @@ licenses:
80
80
  metadata:
81
81
  allowed_push_host: https://rubygems.org/
82
82
  homepage_uri: https://mcfox.com.br
83
- source_code_uri: https://github.com/mcfox/auto_scale_workers
83
+ source_code_uri: https://github.com/mcfox/auto_scale_workers_rails
84
84
  changelog_uri: https://github.com/mcfox/auto_scale_workers/blob/main/CHANGELOG.md
85
85
  post_install_message:
86
86
  rdoc_options: []