auto_scale_workers 0.4.1 → 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: 23ba851b972eb65414a7fb817c093e2380c4aa89086bd1b22d2f5545b115ae27
4
- data.tar.gz: 6e21992796e12e40993fd0de6f1ea686c455edaf5ac0b1716ae03a219f24fde5
3
+ metadata.gz: eb5294640d6aa9edbef12b2b3e477cda9903fb4eb39d0f4f630314dae4145ecf
4
+ data.tar.gz: 61437c8b14d0237cda4af289517cf60017e2aabd437df59a472922f97e2eeebe
5
5
  SHA512:
6
- metadata.gz: 3d1ee29fc40e631edae5df0bda94547235521c96059d96b3d231c442b783474a74aabe0c506b931372a69d0b58ca7375840eea6dab1ead384fb5be1d6c4379eb
7
- data.tar.gz: 4dea0b8699e05d351a18125c34ff1d09f4590d6b5622a33f5745416772f614c373ed7b11ef63a85c807113cc0686905769f319db2477a9135dbde524af71f351
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.1'
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.1
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: []