webhookdb 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webhookdb/async/autoscaler.rb +31 -6
- data/lib/webhookdb/heroku.rb +1 -1
- data/lib/webhookdb/tasks/release.rb +6 -0
- data/lib/webhookdb/version.rb +1 -1
- data/lib/webhookdb.rb +18 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaccd930255b228e07aec00b36d43b6bfc47d0d57fca0ff7fe721e2bee3e09d1
|
4
|
+
data.tar.gz: e51b55c7dd624833ba56d11ecd666e6d3977c8c4e3d92f4b8146c3f8c9c2a47a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b83e8bd2da2e8857e4fbfc4fce5ec2b92ebf22438d047014a337540bfab293412d3327acf13d470cd2063b6f2b712f568e7e225355af8b978a631befc17eea0
|
7
|
+
data.tar.gz: b5ef0bb3313894aab5b8c939905cbbd0f19196a96255ca3346a139b4f9338cedf55ad94ee55ac418395651c6d9a0d9d6949614de5965e651f1ea232354abd33b
|
@@ -9,7 +9,7 @@ module Webhookdb::Async::Autoscaler
|
|
9
9
|
include Appydays::Configurable
|
10
10
|
include Appydays::Loggable
|
11
11
|
|
12
|
-
AVAILABLE_PROVIDERS = ["heroku"].freeze
|
12
|
+
AVAILABLE_PROVIDERS = ["heroku", "fake"].freeze
|
13
13
|
|
14
14
|
def self._check_provider!
|
15
15
|
return if AVAILABLE_PROVIDERS.include?(self.provider)
|
@@ -26,6 +26,8 @@ module Webhookdb::Async::Autoscaler
|
|
26
26
|
setting :max_additional_workers, 2
|
27
27
|
setting :latency_restored_threshold, 0
|
28
28
|
setting :hostname_regex, /^web\.1$/, convert: ->(s) { Regexp.new(s) }
|
29
|
+
setting :heroku_app_id_or_app_name, "", key: "HEROKU_APP_NAME"
|
30
|
+
setting :heroku_formation_id_or_formation_type, "worker"
|
29
31
|
|
30
32
|
after_configured do
|
31
33
|
self._check_provider!
|
@@ -35,19 +37,25 @@ module Webhookdb::Async::Autoscaler
|
|
35
37
|
class << self
|
36
38
|
def enabled? = self.enabled
|
37
39
|
|
38
|
-
def
|
39
|
-
raise "already started" unless @instance.nil?
|
40
|
+
def build_implementation
|
40
41
|
case self.provider
|
41
42
|
when "heroku"
|
42
43
|
opts = {heroku: Webhookdb::Heroku.client, max_additional_workers: self.max_additional_workers}
|
43
44
|
(opts[:app_id_or_app_name] = self.heroku_app_id_or_app_name) if
|
44
|
-
self.heroku_app_id_or_app_name
|
45
|
+
self.heroku_app_id_or_app_name.present?
|
45
46
|
(opts[:formation_id_or_formation_type] = self.heroku_formation_id_or_formation_type) if
|
46
|
-
self.heroku_formation_id_or_formation_type
|
47
|
-
|
47
|
+
self.heroku_formation_id_or_formation_type.present?
|
48
|
+
return Amigo::Autoscaler::Heroku.new(**opts)
|
49
|
+
when "fake"
|
50
|
+
return FakeImplementation.new
|
48
51
|
else
|
49
52
|
self._check_provider!
|
50
53
|
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def start
|
57
|
+
raise "already started" unless @instance.nil?
|
58
|
+
@impl = self.build_implementation
|
51
59
|
@instance = Amigo::Autoscaler.new(
|
52
60
|
poll_interval: self.poll_interval,
|
53
61
|
latency_threshold: self.latency_threshold,
|
@@ -81,4 +89,21 @@ module Webhookdb::Async::Autoscaler
|
|
81
89
|
self.logger.warn("high_latency_queues_resolved", depth:, duration:, scale_action:)
|
82
90
|
end
|
83
91
|
end
|
92
|
+
|
93
|
+
class FakeImplementation
|
94
|
+
attr_reader :scale_ups, :scale_downs
|
95
|
+
|
96
|
+
def initialize
|
97
|
+
@scale_ups = []
|
98
|
+
@scale_downs = []
|
99
|
+
end
|
100
|
+
|
101
|
+
def scale_up(*args)
|
102
|
+
@scale_ups << args
|
103
|
+
end
|
104
|
+
|
105
|
+
def scale_down(*args)
|
106
|
+
@scale_downs << args
|
107
|
+
end
|
108
|
+
end
|
84
109
|
end
|
data/lib/webhookdb/heroku.rb
CHANGED
@@ -14,7 +14,7 @@ class Webhookdb::Heroku
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.client
|
17
|
-
raise "
|
17
|
+
raise "WEBHOOKDB_HEROKU_OAUTH_TOKEN not set" if self.oauth_token.blank?
|
18
18
|
@client ||= PlatformAPI.connect_oauth(self.oauth_token)
|
19
19
|
return @client
|
20
20
|
end
|
@@ -22,6 +22,12 @@ module Webhookdb::Tasks
|
|
22
22
|
Rake::Task["specs:heroku_integration_step1"].invoke
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
desc "Print version info and exit"
|
27
|
+
task :version do
|
28
|
+
sha = Webhookdb::COMMIT[..8]
|
29
|
+
puts "#{sha} (#{Webhookdb::RELEASE}) - #{Webhookdb::RELEASE_CREATED_AT} - #{Webhookdb::RACK_ENV}"
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
end
|
data/lib/webhookdb/version.rb
CHANGED
data/lib/webhookdb.rb
CHANGED
@@ -22,6 +22,17 @@ Money.locale_backend = :i18n
|
|
22
22
|
Money.default_currency = "USD"
|
23
23
|
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
|
24
24
|
|
25
|
+
module Appydays::Configurable
|
26
|
+
def self.fetch_env(keys, default=:__keyerror, env: ENV)
|
27
|
+
keys = [keys] unless keys.respond_to?(:to_ary)
|
28
|
+
keys.to_ary.each do |k|
|
29
|
+
return env.fetch(k) if env.key?(k)
|
30
|
+
end
|
31
|
+
raise KeyError, "no key found in env: #{keys}" if default == :__keyerror
|
32
|
+
return default
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
module Webhookdb
|
26
37
|
include Appydays::Loggable
|
27
38
|
include Appydays::Configurable
|
@@ -49,10 +60,13 @@ module Webhookdb
|
|
49
60
|
class RegressionModeSkip < StandardError; end
|
50
61
|
|
51
62
|
APPLICATION_NAME = "Webhookdb"
|
52
|
-
RACK_ENV =
|
53
|
-
COMMIT =
|
54
|
-
RELEASE =
|
55
|
-
RELEASE_CREATED_AT =
|
63
|
+
RACK_ENV = Appydays::Configurable.fetch_env(["RACK_ENV", "RUBY_ENV"], "development")
|
64
|
+
COMMIT = Appydays::Configurable.fetch_env(["COMMIT", "GIT_SHA", "HEROKU_SLUG_COMMIT"], "00000000")
|
65
|
+
RELEASE = Appydays::Configurable.fetch_env(["RELEASE", "GIT_REF", "HEROKU_RELEASE_VERSION"], "unknown-release")
|
66
|
+
RELEASE_CREATED_AT = Appydays::Configurable.fetch_env(
|
67
|
+
["RELEASE_CREATED_AT", "BUILT_AT", "HEROKU_RELEASE_CREATED_AT"],
|
68
|
+
Time.at(0).utc.iso8601,
|
69
|
+
)
|
56
70
|
INTEGRATION_TESTS_ENABLED = ENV.fetch("INTEGRATION_TESTS", false)
|
57
71
|
require "webhookdb/version"
|
58
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhookdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WebhookDB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|