neetodeploy-autoscale 1.0.4 → 1.0.6

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: 6f0190f5084eb35624b7794eee1edbaf90336fb9933e14ac1e341eb7f01d9702
4
- data.tar.gz: b0fed28441c978afd8e92d2b9d1dbb6e76a3d83b8072277f0e98c67cab08e541
3
+ metadata.gz: 50af0e2a9a2c425e9f496a34540b996ba5bad120e6f0f12a4d4f97d778c5141b
4
+ data.tar.gz: b2dec0286ccc386f4908a7f409c14cd6c2bb6d9f81025b2164f10eb849c1c620
5
5
  SHA512:
6
- metadata.gz: 70f9f059a6262ec11c1b0cfea4f09de2cc923d896a0f268fba3f5d464f95e86128732013d838ea333b21bc5ef573c6e1bc334022ece7b144b173e3d1a9d37f2b
7
- data.tar.gz: 44771bb2959cb361bc66112aef8e74ea23e90a8f51bbe12f985b7d91c3796ef13c0a0f01851761c0d8ee5c6f80038164e9addb68e0560543b34a061337eb55d8
6
+ metadata.gz: 425ba48cac96eef297bb510cf960f904ec760008dca4df78c3bbaad09253f028be24ad17a50fb5729694a3a99504627defdd42a53952dfeaf39b123503a9fab3
7
+ data.tar.gz: 0bb779eb933fbd7eaf4edfe854b103d717c880cadecfdf4b00e8e7d3267e2995045a62c69d740c73abfa9db78ac200c9b8bd95dd82f1f5595229dae73fdba26f
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "time"
5
+
6
+ module Neetodeploy
7
+ class Exporter
8
+ def self.export(payload)
9
+ Thread.new do
10
+ url = URI.parse("http://nd-queue-time-exporter-web-deployment:3000/metrics")
11
+ url.query = payload
12
+ post = Net::HTTP::Post.new(url)
13
+ post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy"
14
+
15
+ Net::HTTP.start(url.host, url.port, use_ssl: false) do |http|
16
+ http.request(post)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,15 +2,13 @@
2
2
 
3
3
  require "net/http"
4
4
  require "time"
5
- require "neetodeploy/autoscale/worker"
5
+ require "neetodeploy/autoscale/exporter"
6
6
 
7
7
  module Neetodeploy
8
8
  class Middleware
9
- attr_reader :worker
10
9
 
11
10
  def initialize(app)
12
11
  @app = app
13
- init_worker
14
12
  end
15
13
 
16
14
  def call(env)
@@ -19,7 +17,7 @@ module Neetodeploy
19
17
  process_type: "web",
20
18
  queue_time: queue_time(env)
21
19
  )
22
- worker.push(payload)
20
+ Neetodeploy::Exporter.export(payload)
23
21
  @app.call(env)
24
22
  end
25
23
 
@@ -43,11 +41,5 @@ module Neetodeploy
43
41
 
44
42
  queue_time.positive? ? queue_time : 0
45
43
  end
46
-
47
- def init_worker
48
- return if @worker
49
-
50
- @worker = Neetodeploy::Worker.new
51
- end
52
44
  end
53
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neetodeploy
4
4
  module Autoscale
5
- VERSION = "1.0.4"
5
+ VERSION = "1.0.6"
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: 1.0.4
4
+ version: 1.0.6
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-08-16 00:00:00.000000000 Z
11
+ date: 2025-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: For automatically scaling your Rails application based on network metrics
14
14
  email:
@@ -23,11 +23,11 @@ files:
23
23
  - README.md
24
24
  - Rakefile
25
25
  - lib/neetodeploy-autoscale.rb
26
+ - lib/neetodeploy/autoscale/exporter.rb
26
27
  - lib/neetodeploy/autoscale/middleware.rb
27
28
  - lib/neetodeploy/autoscale/railtie.rb
28
29
  - lib/neetodeploy/autoscale/sidekiq_middleware.rb
29
30
  - lib/neetodeploy/autoscale/version.rb
30
- - lib/neetodeploy/autoscale/worker.rb
31
31
  homepage: https://neetodeploy.com
32
32
  licenses: []
33
33
  metadata:
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.1.6
52
+ rubygems_version: 3.4.19
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: neetoDeploy autoscaler gem
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "net/http"
4
- require "time"
5
-
6
- module Neetodeploy
7
- class Worker
8
- attr_reader :mutex, :queue, :thread
9
-
10
- def initialize
11
- @mutex = Mutex.new
12
- @queue = Queue.new
13
-
14
- end
15
-
16
- def push(msg)
17
- start && queue.push(msg)
18
- end
19
-
20
- def start
21
- mutex.synchronize do
22
- return true if thread&.alive?
23
-
24
- @thread = Thread.new { run }
25
- end
26
- true
27
- end
28
-
29
- private
30
-
31
- def run
32
- puts "neetodeploy-autoscale: reporter worker started"
33
- until queue.empty?
34
- queue_time = queue.pop
35
- work(queue_time)
36
- end
37
- puts "neetodeploy-autoscale: reporter stopping worker"
38
- end
39
-
40
- def work(payload)
41
- url = URI.parse("http://nd-queue-time-exporter-web-deployment:3000/metrics")
42
- url.query = payload
43
- post = Net::HTTP::Post.new(url)
44
- post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy"
45
-
46
- begin
47
- Net::HTTP.start(url.host, url.port, use_ssl: false) do |http|
48
- response = http.request(post)
49
- end
50
- rescue StandardError => e
51
- puts "Exception in sending post request to exporter from Rails process: #{e.message}"
52
- end
53
- end
54
- end
55
- end