neetodeploy-autoscale 0.5.0 → 0.7.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae89d71a8dc745af2e4af2c94a94c16497a2067ec5fbc31e1ad351f5f84bd333
|
4
|
+
data.tar.gz: 69e44e72990b27b8ea1e6c9398f74af6b7c73d8dfb5dc0bc3c0995821da8c16a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc14913a507e277fb7e76a5917053e7a7a2cc4039a3180e5cb5625b3807f23c72c244e0a60774a24c26d35ffae3834c4bff4d3a2fc264e19006b49308b741112
|
7
|
+
data.tar.gz: af10749f4ab0e928fe3564c9ee86fb4933bace261e7d3a8e59a4032e596a557f88506dca517c7852790b758ef7b808d8abd6ae2d06083cc7deb72ada008b5885
|
@@ -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: true) 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
|
@@ -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
|
-
|
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.
|
4
|
+
version: 0.7.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-
|
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.
|
51
|
+
rubygems_version: 3.3.26
|
51
52
|
signing_key:
|
52
53
|
specification_version: 4
|
53
54
|
summary: neetoDeploy autoscaler gem
|