pigeon-http 0.1.2 → 0.1.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pigeon/core.rb +17 -17
- data/lib/pigeon/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: 204c0c65ca18699400c662cdce4813337fa5f270a15012c63279ab03e1fb35c4
|
4
|
+
data.tar.gz: f2c2070ca2ab97182b0574ecf281759a14cee4b7d7d42f42ce23d97b8a8a0ace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f66c5ce34abe98064138ade62435d182a0592ee147799b52c199e19893f5b5c66dc01d5a3d7755efc7b9c330fb95d74e539d8176637b8fbda03b6baa31fce4a
|
7
|
+
data.tar.gz: 72cc4bbac4814d99f6f3a79fdfe49a261cc65a7044706e8736469e61fb1b90ed5ca2edd07a47cc93f313c949bd7605b1f4982bfaf65990f08431b9a2b11dba58
|
data/Gemfile.lock
CHANGED
data/lib/pigeon/core.rb
CHANGED
@@ -18,10 +18,11 @@ rescue LoadError => e
|
|
18
18
|
end
|
19
19
|
|
20
20
|
module Pigeon
|
21
|
-
VALID_OPTIONS = %w[request_timeout request_open_timeout ssl_verify volume_threshold error_threshold time_window sleep_window retryable retry_threshold].freeze
|
21
|
+
VALID_OPTIONS = %w[environment request_timeout request_open_timeout ssl_verify volume_threshold error_threshold time_window sleep_window retryable retry_threshold monitoring monitoring_type].freeze
|
22
22
|
VALID_CALLBACKS = %w[CircuitBreakerOpen CircuitBreakerClose HttpSuccess HttpError RetrySuccess RetryFailure]
|
23
23
|
|
24
24
|
DEFAULT_OPTIONS = {
|
25
|
+
environment: 'default',
|
25
26
|
request_name: 'pigeon_default',
|
26
27
|
request_timeout: 60,
|
27
28
|
request_open_timeout: 0,
|
@@ -32,7 +33,8 @@ module Pigeon
|
|
32
33
|
sleep_window: 10,
|
33
34
|
retryable: true,
|
34
35
|
retry_threshold: 3,
|
35
|
-
monitoring: false
|
36
|
+
monitoring: false,
|
37
|
+
monitoring_type: 'datadog'
|
36
38
|
}
|
37
39
|
DEFAULT_CALLBACKS = {
|
38
40
|
CircuitBreakerOpen: nil,
|
@@ -69,51 +71,49 @@ module Pigeon
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
74
|
+
def config key, value
|
75
|
+
raise Error::Argument, "unknown option #{key}" unless VALID_OPTIONS.include?(key.to_s)
|
76
|
+
@options[key.to_sym] = value
|
77
|
+
end
|
78
|
+
|
72
79
|
def get url, args = {}
|
73
|
-
start = Time.now
|
74
80
|
response = http(:get, url, args)
|
75
|
-
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: [url]).capture(action: :histogram, count: (Time.now - start)) unless @options[:monitoring]
|
76
|
-
|
77
|
-
response
|
78
81
|
rescue => e
|
82
|
+
puts e
|
79
83
|
@callbacks[:HttpError]&.call(e)
|
80
84
|
end
|
81
85
|
|
82
86
|
def post url, args = {}
|
83
|
-
start = Time.now
|
84
87
|
response = http(:post, url, args)
|
85
|
-
puts @options
|
86
|
-
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: [url]).capture(action: :histogram, count: (Time.now - start)) unless @options[:monitoring]
|
87
|
-
|
88
|
-
response
|
89
88
|
rescue => e
|
90
89
|
@callbacks[:HttpError]&.call(e)
|
91
90
|
end
|
92
91
|
|
93
92
|
def put url, args = {}
|
94
|
-
start = Time.now
|
95
93
|
response = http(:put, url, args)
|
96
|
-
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: [url]).capture(action: :histogram, count: (Time.now - start)) unless @options[:monitoring]
|
97
|
-
|
98
|
-
response
|
99
94
|
rescue => e
|
100
95
|
@callbacks[:HttpError]&.call(e)
|
101
96
|
end
|
102
97
|
|
103
98
|
def delete url, args = {}
|
104
|
-
http(:delete, url, args)
|
99
|
+
response = http(:delete, url, args)
|
105
100
|
rescue => e
|
106
101
|
@callbacks[:HttpError]&.call(e)
|
107
102
|
end
|
108
103
|
|
109
104
|
def http method, url, args = {}
|
105
|
+
start = Time.now
|
110
106
|
args.merge({
|
111
107
|
read_timeout: @options[:request_timeout],
|
112
108
|
open_timeout: @options[:request_open_timeout],
|
113
109
|
ssl_verify: @options[:ssl_verify]
|
114
110
|
})
|
115
111
|
response = Pigeon::Http::Request.new(method, url, args).execute
|
116
|
-
|
112
|
+
|
113
|
+
uri = URI.parse(url)
|
114
|
+
Pigeon::Statsd.new(@options[:request_name] + '_latency', tags: [uri.host]).capture(action: :histogram, count: (Time.now - start))
|
115
|
+
Pigeon::Statsd.new(@options[:request_name] + '_througput', tags: [uri.host]).capture
|
116
|
+
Pigeon::Statsd.new(@options[:request_name] + '_status', tags: [response.code]).capture
|
117
117
|
|
118
118
|
response
|
119
119
|
end
|
data/lib/pigeon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pigeon-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fitra Aditya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: circuitbox
|