neetodeploy-autoscale 0.5.0 → 0.6.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: c0eba17ecdf99b87711ea1607f3497bba260a773aebf6c064f225916f1bce0ab
4
- data.tar.gz: 5d38a45b75d33207f55f539955e9dddc27294cdbc402c2f181086f7f343ae4d5
3
+ metadata.gz: b0b25708e10d77c473b33ff4f46b1537b0977bb18c990f54bdf33afc4b3a6947
4
+ data.tar.gz: d2faea5f93812588a2850b5cf5e2bb84e5efbf3295331e7340f2153d43ec2841
5
5
  SHA512:
6
- metadata.gz: fdad9d224da3024944b8f92d5157b9aeee1bbabac81d9d757efb0811cc265720381f4ae88db36fc985381ff5f179d30a4236ca2a5346d0e653041ee5464b2eea
7
- data.tar.gz: b98a32aab20efb3228968ed211523d947cce385c275e83159c108aa4252f6817b633077b65f2699df7af77a5a801ed445c2dda7a734f9f93601f8cf0268d94eb
6
+ metadata.gz: a732fd7615496308c4e10da3b73dfbdf82e0713d906719e618e9a07fc1611a279b12186ff232b467ae2c42663dc4314b592c848810acc3882af006806bce3220
7
+ data.tar.gz: b9b4ee9cbb20796597ca64dfd4c0d621c2f88b66655544c3e0f376c3e0defd71b261f489f3ccd90ddbdd087e3059bed8147d96ee84e3a0edf6e5f539b039efdf
@@ -12,7 +12,7 @@ module Neetodeploy
12
12
  def call(env)
13
13
  url = URI.parse("https://nd-queue-time-exporter.neetodeployapp.com/metrics")
14
14
 
15
- query_params = URI.encode_www_form(app_name: ENV.to_h["NEETODEPLOY_APP_NAME"], queue_time: queue_time(env))
15
+ query_params = URI.encode_www_form(app_name: ENV.to_h["NEETODEPLOY_APP_NAME"], process_type: "web", queue_time: queue_time(env))
16
16
 
17
17
  url.query = query_params
18
18
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "time"
5
+
6
+ module Neetodeploy
7
+ class SidekiqMiddleware
8
+ def call(worker, job, queue)
9
+ url = URI.parse("https://nd-queue-time-exporter.neetodeployapp.com/metrics")
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))
12
+
13
+ url.query = query_params
14
+
15
+ post = Net::HTTP::Post.new(url)
16
+ post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy"
17
+
18
+ Net::HTTP.start(url.host, url.port, use_ssl: false) do |http|
19
+ http.request(post)
20
+ end
21
+
22
+ yield
23
+ end
24
+
25
+ private
26
+
27
+ def queue_time(worker, job, queue)
28
+ (Time.now - Time.at(job["created_at"])) * 1000
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neetodeploy
4
4
  module Autoscale
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -5,10 +5,29 @@ require_relative "neetodeploy/autoscale/version"
5
5
  module Neetodeploy
6
6
  module Autoscale
7
7
  class Error < StandardError; end
8
+
9
+ class << self
10
+ def setup_middleware
11
+ require "neetodeploy/autoscale/middleware"
12
+ Neetodeploy::Autoscale.setup_rails if defined? Rails
13
+ Neetodeploy::Autoscale.setup_sidekiq if defined?(Sidekiq)
14
+ end
15
+
16
+ def setup_rails
17
+ require "neetodeploy/autoscale/railtie"
18
+ end
19
+
20
+ def setup_sidekiq
21
+ require "neetodeploy/autoscale/sidekiq_middleware"
22
+
23
+ Sidekiq.configure_server do |config|
24
+ config.server_middleware do |chain|
25
+ chain.add Neetodeploy::SidekiqMiddleware
26
+ end
27
+ end
28
+ end
29
+ end
8
30
  end
9
31
  end
10
32
 
11
- if ENV.to_h["NEETODEPLOY_APP_NAME"].present?
12
- require "neetodeploy/autoscale/middleware"
13
- require "neetodeploy/autoscale/railtie" if defined? Rails
14
- end
33
+ ENV.to_h["NEETODEPLOY_APP_NAME"].present? && Neetodeploy::Autoscale.setup_middleware
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.5.0
4
+ version: 0.6.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-07 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: For automatically scaling your Rails application based on network metrics
14
14
  email:
@@ -25,6 +25,7 @@ files:
25
25
  - lib/neetodeploy-autoscale.rb
26
26
  - lib/neetodeploy/autoscale/middleware.rb
27
27
  - lib/neetodeploy/autoscale/railtie.rb
28
+ - lib/neetodeploy/autoscale/sidekiq_middleware.rb
28
29
  - lib/neetodeploy/autoscale/version.rb
29
30
  homepage: https://neetodeploy.com
30
31
  licenses: []
@@ -47,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
48
  - !ruby/object:Gem::Version
48
49
  version: '0'
49
50
  requirements: []
50
- rubygems_version: 3.3.7
51
+ rubygems_version: 3.3.26
51
52
  signing_key:
52
53
  specification_version: 4
53
54
  summary: neetoDeploy autoscaler gem