kennel 1.26.1 → 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kennel/api.rb +10 -5
- data/lib/kennel/models/dash.rb +2 -0
- data/lib/kennel/models/monitor.rb +2 -0
- data/lib/kennel/models/screen.rb +2 -0
- data/lib/kennel/optional_validations.rb +17 -0
- data/lib/kennel/utils.rb +9 -0
- data/lib/kennel/version.rb +1 -1
- 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: 0e5b0226f92f89c176e7591b3f3f1dc5fbccce47c540f28110d5860416b33e17
|
4
|
+
data.tar.gz: 1cdc34e2b90c0e99381d275747742661bc0828a649701f4490673e788d47341b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af7a3063ed49c51634c0fec06e1b6749bc8aa30857f2c2135376c80799a10856ae44acc27fc91ddf21500f1e4069396cdcc886365291c789a35f459236cc0ac
|
7
|
+
data.tar.gz: 249d02adb861130b88ea1ad17e26f5b19ca95fb729c3b3af4ae7f473a5b6e65198faa57431670e54079289aa0f6497eab1917b1fdbbba996bed568bc25b8df01
|
data/lib/kennel/api.rb
CHANGED
@@ -33,13 +33,18 @@ module Kennel
|
|
33
33
|
params = params.merge(application_key: @app_key, api_key: @api_key)
|
34
34
|
query = Faraday::FlatParamsEncoder.encode(params)
|
35
35
|
response = nil
|
36
|
+
tries = 2
|
36
37
|
|
37
|
-
|
38
|
-
response =
|
39
|
-
|
40
|
-
|
38
|
+
tries.times do |i|
|
39
|
+
response = Utils.retry Faraday::ConnectionFailed, times: 2 do
|
40
|
+
@client.send(method, "#{path}?#{query}") do |request|
|
41
|
+
request.body = JSON.generate(body) if body
|
42
|
+
request.headers["Content-type"] = "application/json"
|
43
|
+
end
|
41
44
|
end
|
42
|
-
|
45
|
+
|
46
|
+
break if i == tries - 1 || method != :get || response.status < 500
|
47
|
+
Kennel.err.puts "Retrying on server error #{response.status} for #{path}"
|
43
48
|
end
|
44
49
|
|
45
50
|
unless response.success?
|
data/lib/kennel/models/dash.rb
CHANGED
data/lib/kennel/models/screen.rb
CHANGED
@@ -5,5 +5,22 @@ module Kennel
|
|
5
5
|
base.settings :validate
|
6
6
|
base.defaults(validate: -> { true })
|
7
7
|
end
|
8
|
+
|
9
|
+
# https://stackoverflow.com/questions/20235206/ruby-get-all-keys-in-a-hash-including-sub-keys/53876255#53876255
|
10
|
+
def self.all_keys(items)
|
11
|
+
case items
|
12
|
+
when Hash then items.keys + items.values.flat_map { |v| all_keys(v) }
|
13
|
+
when Array then items.flat_map { |i| all_keys(i) }
|
14
|
+
else []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def validate_json(data)
|
21
|
+
bad = OptionalValidations.all_keys(data).grep_v(Symbol)
|
22
|
+
return if bad.empty?
|
23
|
+
invalid! "only use Symbols to avoid permanent diffs (#{bad.map(&:inspect).join(", ")})"
|
24
|
+
end
|
8
25
|
end
|
9
26
|
end
|
data/lib/kennel/utils.rb
CHANGED
@@ -114,6 +114,15 @@ module Kennel
|
|
114
114
|
def natural_order(name)
|
115
115
|
name.split(/(\d+)/).each_with_index.map { |x, i| i.odd? ? x.to_i : x }
|
116
116
|
end
|
117
|
+
|
118
|
+
def retry(*errors, times:)
|
119
|
+
yield
|
120
|
+
rescue *errors => e
|
121
|
+
times -= 1
|
122
|
+
raise if times < 0
|
123
|
+
Kennel.err.puts "Error #{e}, #{times} retries left"
|
124
|
+
retry
|
125
|
+
end
|
117
126
|
end
|
118
127
|
end
|
119
128
|
end
|
data/lib/kennel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kennel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|