auto_scale_workers 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb5294640d6aa9edbef12b2b3e477cda9903fb4eb39d0f4f630314dae4145ecf
|
4
|
+
data.tar.gz: 61437c8b14d0237cda4af289517cf60017e2aabd437df59a472922f97e2eeebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da94a1419740f84a2581f5556a613b724c2f0bcc4f358c9c829caec3dcb703e30b8103c15733ee56da5a2f03972530388668cc27d5dab75d5e5f16d25455dc23
|
7
|
+
data.tar.gz: a94465256d6532a53fc5a4fa14c125151c5d7a8cbad5f0b9b620821c1ee59f18658ab0e5a5eccf759c491a90d86a63084d5b2e68b8f64ee0a3f3d0957afbbf6f
|
data/auto_scale_workers.gemspec
CHANGED
@@ -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/
|
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
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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 "
|
18
|
-
# Faça algo com response.body ou response.parsed_response, se necessário
|
30
|
+
puts "Posted do ASW"
|
19
31
|
else
|
20
|
-
|
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]
|
10
|
-
|
11
|
-
|
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
|
data/lib/auto_scale_workers.rb
CHANGED
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.
|
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-
|
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/
|
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: []
|