getaround_utils 0.1.13 → 0.1.14
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 +4 -0
- data/Gemfile.lock +18 -2
- data/lib/getaround_utils/utils/async_queue.rb +57 -0
- data/lib/getaround_utils/utils/http_reporter.rb +26 -0
- data/lib/getaround_utils/utils.rb +2 -0
- data/lib/getaround_utils/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60fc9ba7221e390c7e38bafe4eb9081b92c2f7bbaa712ec6d406829119caa078
|
4
|
+
data.tar.gz: 8e15c5d248d959feafa0e5c8138fdbb98b390ac3ea57cb3fe210664a06d62b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d82749e52098b299e05f1a86bbd7a1c0c41740b2f49a6ce141cfb59d3ca8d357c0934f986ae367e93b148acc40fb625ebefb46499e53ab508ef155fee3b6944
|
7
|
+
data.tar.gz: 4f133ab4291622815841b92dbd195b89e8a04ba076c083536292ed6115b47a6aa1407a9ea4db0199b6f156c9da30bd61ae8b81f2a7abb4c34d6938249e9122c3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
getaround_utils (0.1.
|
4
|
+
getaround_utils (0.1.14)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -61,19 +61,26 @@ GEM
|
|
61
61
|
minitest (~> 5.1)
|
62
62
|
tzinfo (~> 1.1)
|
63
63
|
zeitwerk (~> 2.1, >= 2.1.8)
|
64
|
+
addressable (2.7.0)
|
65
|
+
public_suffix (>= 2.0.2, < 5.0)
|
64
66
|
ast (2.4.0)
|
65
67
|
builder (3.2.3)
|
66
68
|
coderay (1.1.2)
|
67
69
|
concurrent-ruby (1.1.5)
|
68
70
|
connection_pool (2.2.2)
|
71
|
+
crack (0.4.3)
|
72
|
+
safe_yaml (~> 1.0.0)
|
69
73
|
crass (1.0.5)
|
70
74
|
diff-lcs (1.3)
|
71
75
|
erubi (1.9.0)
|
76
|
+
faraday (1.0.0)
|
77
|
+
multipart-post (>= 1.2, < 3)
|
72
78
|
getaround-rubocop (0.1.0)
|
73
79
|
relaxed-rubocop (~> 2.4, >= 2.4.0)
|
74
80
|
rubocop (~> 0.75, >= 0.75.0)
|
75
81
|
globalid (0.4.2)
|
76
82
|
activesupport (>= 4.2.0)
|
83
|
+
hashdiff (1.0.0)
|
77
84
|
i18n (1.7.0)
|
78
85
|
concurrent-ruby (~> 1.0)
|
79
86
|
jaro_winkler (1.5.4)
|
@@ -94,6 +101,7 @@ GEM
|
|
94
101
|
mini_mime (1.0.2)
|
95
102
|
mini_portile2 (2.4.0)
|
96
103
|
minitest (5.13.0)
|
104
|
+
multipart-post (2.1.1)
|
97
105
|
nio4r (2.5.2)
|
98
106
|
nokogiri (1.10.5)
|
99
107
|
mini_portile2 (~> 2.4.0)
|
@@ -103,6 +111,7 @@ GEM
|
|
103
111
|
pry (0.12.2)
|
104
112
|
coderay (~> 1.1.0)
|
105
113
|
method_source (~> 0.9.0)
|
114
|
+
public_suffix (4.0.2)
|
106
115
|
rack (2.0.7)
|
107
116
|
rack-protection (2.0.7)
|
108
117
|
rack
|
@@ -171,6 +180,7 @@ GEM
|
|
171
180
|
rubocop-rspec (1.36.0)
|
172
181
|
rubocop (>= 0.68.1)
|
173
182
|
ruby-progressbar (1.10.1)
|
183
|
+
safe_yaml (1.0.5)
|
174
184
|
sidekiq (6.0.3)
|
175
185
|
connection_pool (>= 2.2.2)
|
176
186
|
rack (>= 2.0.0)
|
@@ -188,6 +198,10 @@ GEM
|
|
188
198
|
tzinfo (1.2.5)
|
189
199
|
thread_safe (~> 0.1)
|
190
200
|
unicode-display_width (1.6.0)
|
201
|
+
webmock (3.7.6)
|
202
|
+
addressable (>= 2.3.6)
|
203
|
+
crack (>= 0.3.2)
|
204
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
191
205
|
websocket-driver (0.7.1)
|
192
206
|
websocket-extensions (>= 0.1.0)
|
193
207
|
websocket-extensions (0.1.4)
|
@@ -198,6 +212,7 @@ PLATFORMS
|
|
198
212
|
|
199
213
|
DEPENDENCIES
|
200
214
|
bundler (~> 2.0)
|
215
|
+
faraday (~> 1.0)
|
201
216
|
getaround-rubocop (~> 0.1.0, >= 0.1.0)
|
202
217
|
getaround_utils!
|
203
218
|
lograge (~> 0.11.2)
|
@@ -209,6 +224,7 @@ DEPENDENCIES
|
|
209
224
|
rubocop (~> 0.75, >= 0.75.0)
|
210
225
|
rubocop-rspec (~> 1.36, >= 0.36.0)
|
211
226
|
sidekiq (~> 6.0)
|
227
|
+
webmock (~> 3.7)
|
212
228
|
|
213
229
|
BUNDLED WITH
|
214
|
-
2.0
|
230
|
+
2.1.0
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module GetaroundUtils; end
|
2
|
+
module GetaroundUtils::Utils; end
|
3
|
+
|
4
|
+
class GetaroundUtils::Utils::AsyncQueue
|
5
|
+
class << self
|
6
|
+
include GetaroundUtils::Mixins::Loggable
|
7
|
+
|
8
|
+
MAX_QUEUE_SIZE = 100
|
9
|
+
MUTEX = Mutex.new
|
10
|
+
|
11
|
+
def perform
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform_async(*args)
|
16
|
+
start_once!
|
17
|
+
|
18
|
+
if @queue.size > MAX_QUEUE_SIZE
|
19
|
+
loggable('warn', 'Queue is overflowing')
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
@queue.push(args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_once!
|
27
|
+
MUTEX.synchronize do
|
28
|
+
return unless @parent.nil?
|
29
|
+
|
30
|
+
@parent = Process.pid
|
31
|
+
@queue = Queue.new
|
32
|
+
|
33
|
+
@worker = Thread.new do
|
34
|
+
while args = @queue.pop
|
35
|
+
perform(*args)
|
36
|
+
end
|
37
|
+
rescue ClosedQueueError
|
38
|
+
nil
|
39
|
+
rescue StandardError => e
|
40
|
+
loggable('error', e.message, class: e.class.to_s, backtrace: e.backtrace)
|
41
|
+
end
|
42
|
+
|
43
|
+
at_exit { terminate }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def terminate
|
48
|
+
@queue&.close
|
49
|
+
@worker&.join
|
50
|
+
end
|
51
|
+
|
52
|
+
def reset
|
53
|
+
terminate
|
54
|
+
@parent = nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
class GetaroundUtils::Utils::HttpReporter
|
5
|
+
class AsyncQueue < GetaroundUtils::Utils::AsyncQueue
|
6
|
+
def self.perform(url:, params: {}, headers: {}, body: nil)
|
7
|
+
Faraday.post(url) do |req|
|
8
|
+
req.params = params
|
9
|
+
req.headers = headers
|
10
|
+
req.body = body
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(url:)
|
16
|
+
@url = url
|
17
|
+
end
|
18
|
+
|
19
|
+
def report(event)
|
20
|
+
AsyncQueue.perform_async(
|
21
|
+
url: @url,
|
22
|
+
headers: { 'Content-Type' => 'application/json' },
|
23
|
+
body: JSON.generate(event)
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getaround_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drivy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -212,7 +212,9 @@ files:
|
|
212
212
|
- lib/getaround_utils/patches/key_value_sidekiq_exceptions.rb
|
213
213
|
- lib/getaround_utils/railties/lograge.rb
|
214
214
|
- lib/getaround_utils/utils.rb
|
215
|
+
- lib/getaround_utils/utils/async_queue.rb
|
215
216
|
- lib/getaround_utils/utils/deep_key_value.rb
|
217
|
+
- lib/getaround_utils/utils/http_reporter.rb
|
216
218
|
- lib/getaround_utils/version.rb
|
217
219
|
homepage: https://github.com/drivy
|
218
220
|
licenses:
|