bloodbath 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec_status +12 -8
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +18 -1
- data/fixtures/vcr_cassettes/Bloodbath_Event/_cancel/1_4_1.yml +229 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_cancel/_cancel/1_4_2_1.yml +41 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_find/1_3_1.yml +191 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_find/_find/1_3_2_1.yml +41 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_list/1_2_1.yml +78 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_list/_list/1_2_1_1.yml +51 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_schedule/1_1_1.yml +325 -0
- data/fixtures/vcr_cassettes/Bloodbath_Event/_schedule/_schedule/1_1_2_1.yml +44 -0
- data/lib/bloodbath/configuration.rb +1 -1
- data/lib/bloodbath/event.rb +52 -18
- data/lib/bloodbath/utils/threading.rb +42 -0
- data/lib/bloodbath/version.rb +1 -1
- metadata +8 -3
@@ -41,4 +41,329 @@ http_interactions:
|
|
41
41
|
encoding: UTF-8
|
42
42
|
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"1542e6eb-1ecf-48ed-b43e-692b90ce16c3","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-05-27T23:09:34Z"}}'
|
43
43
|
recorded_at: Thu, 27 May 2021 22:09:34 GMT
|
44
|
+
- request:
|
45
|
+
method: post
|
46
|
+
uri: http://localhost:4000/rest/events
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"scheduled_for":"2021-11-02 01:00:05 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
50
|
+
body","endpoint":"https://api.fake-site.com"}'
|
51
|
+
headers:
|
52
|
+
Accept-Encoding:
|
53
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
54
|
+
Accept:
|
55
|
+
- "*/*"
|
56
|
+
User-Agent:
|
57
|
+
- Ruby
|
58
|
+
Authorization:
|
59
|
+
- Bearer TONnZlNFWYG6CZ36v4tAwfA4UKRVX3_Ou8LNRmbkSFspd4xBl3oVaKkr_UfsAL2bgg_k39ENVzY1F90urvsBVA==
|
60
|
+
Content-Type:
|
61
|
+
- application/json
|
62
|
+
response:
|
63
|
+
status:
|
64
|
+
code: 401
|
65
|
+
message: Unauthorized
|
66
|
+
headers:
|
67
|
+
Cache-Control:
|
68
|
+
- max-age=0, private, must-revalidate
|
69
|
+
Content-Length:
|
70
|
+
- '157'
|
71
|
+
Content-Type:
|
72
|
+
- application/json; charset=utf-8
|
73
|
+
Date:
|
74
|
+
- Mon, 01 Nov 2021 23:00:06 GMT
|
75
|
+
Server:
|
76
|
+
- Cowboy
|
77
|
+
X-Request-Id:
|
78
|
+
- FrOOWc0NhZjkE6YAABGM
|
79
|
+
body:
|
80
|
+
encoding: UTF-8
|
81
|
+
string: '{"errors":["Your API key isn''t valid. Please read https://bloodbath.notion.site/Acquire-your-API-Key-3b4adbbcc7f948d0a5c52d165a963ae4
|
82
|
+
for more information"]}'
|
83
|
+
recorded_at: Mon, 01 Nov 2021 23:00:06 GMT
|
84
|
+
- request:
|
85
|
+
method: post
|
86
|
+
uri: http://localhost:4000/rest/events
|
87
|
+
body:
|
88
|
+
encoding: UTF-8
|
89
|
+
string: '{"scheduled_for":"2021-11-02 01:05:10 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
90
|
+
body","endpoint":"https://api.fake-site.com"}'
|
91
|
+
headers:
|
92
|
+
Accept-Encoding:
|
93
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
94
|
+
Accept:
|
95
|
+
- "*/*"
|
96
|
+
User-Agent:
|
97
|
+
- Ruby
|
98
|
+
Authorization:
|
99
|
+
- Bearer RIi9yhM42RDgEXLiVbO3z-ncbS2GvI3fcmwYL4f2Zf0JpyUUKCAx8M6glyHnLmyN8Kkbul9VoAai6798ssu4aw==
|
100
|
+
Content-Type:
|
101
|
+
- application/json
|
102
|
+
response:
|
103
|
+
status:
|
104
|
+
code: 401
|
105
|
+
message: Unauthorized
|
106
|
+
headers:
|
107
|
+
Cache-Control:
|
108
|
+
- max-age=0, private, must-revalidate
|
109
|
+
Content-Length:
|
110
|
+
- '157'
|
111
|
+
Content-Type:
|
112
|
+
- application/json; charset=utf-8
|
113
|
+
Date:
|
114
|
+
- Mon, 01 Nov 2021 23:05:10 GMT
|
115
|
+
Server:
|
116
|
+
- Cowboy
|
117
|
+
X-Request-Id:
|
118
|
+
- FrOOoLI8k8Ap8-MAAAIB
|
119
|
+
body:
|
120
|
+
encoding: UTF-8
|
121
|
+
string: '{"errors":["Your API key isn''t valid. Please read https://bloodbath.notion.site/Acquire-your-API-Key-3b4adbbcc7f948d0a5c52d165a963ae4
|
122
|
+
for more information"]}'
|
123
|
+
recorded_at: Mon, 01 Nov 2021 23:05:10 GMT
|
124
|
+
- request:
|
125
|
+
method: post
|
126
|
+
uri: http://localhost:4000/rest/events
|
127
|
+
body:
|
128
|
+
encoding: UTF-8
|
129
|
+
string: '{"scheduled_for":"2021-11-02 01:05:34 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
130
|
+
body","endpoint":"https://api.fake-site.com"}'
|
131
|
+
headers:
|
132
|
+
Accept-Encoding:
|
133
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
134
|
+
Accept:
|
135
|
+
- "*/*"
|
136
|
+
User-Agent:
|
137
|
+
- Ruby
|
138
|
+
Authorization:
|
139
|
+
- Bearer RIi9yhM42RDgEXLiVbO3z-ncbS2GvI3fcmwYL4f2Zf0JpyUUKCAx8M6glyHnLmyN8Kkbul9VoAai6798ssu4aw==
|
140
|
+
Content-Type:
|
141
|
+
- application/json
|
142
|
+
response:
|
143
|
+
status:
|
144
|
+
code: 401
|
145
|
+
message: Unauthorized
|
146
|
+
headers:
|
147
|
+
Cache-Control:
|
148
|
+
- max-age=0, private, must-revalidate
|
149
|
+
Content-Length:
|
150
|
+
- '157'
|
151
|
+
Content-Type:
|
152
|
+
- application/json; charset=utf-8
|
153
|
+
Date:
|
154
|
+
- Mon, 01 Nov 2021 23:05:34 GMT
|
155
|
+
Server:
|
156
|
+
- Cowboy
|
157
|
+
X-Request-Id:
|
158
|
+
- FrOOplk5dLg8J2oAAAJM
|
159
|
+
body:
|
160
|
+
encoding: UTF-8
|
161
|
+
string: '{"errors":["Your API key isn''t valid. Please read https://bloodbath.notion.site/Acquire-your-API-Key-3b4adbbcc7f948d0a5c52d165a963ae4
|
162
|
+
for more information"]}'
|
163
|
+
recorded_at: Mon, 01 Nov 2021 23:05:34 GMT
|
164
|
+
- request:
|
165
|
+
method: post
|
166
|
+
uri: http://localhost:4000/rest/events
|
167
|
+
body:
|
168
|
+
encoding: UTF-8
|
169
|
+
string: '{"scheduled_for":"2021-11-02 01:08:31 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
170
|
+
body","endpoint":"https://api.fake-site.com"}'
|
171
|
+
headers:
|
172
|
+
Accept-Encoding:
|
173
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
174
|
+
Accept:
|
175
|
+
- "*/*"
|
176
|
+
User-Agent:
|
177
|
+
- Ruby
|
178
|
+
Authorization:
|
179
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
180
|
+
Content-Type:
|
181
|
+
- application/json
|
182
|
+
response:
|
183
|
+
status:
|
184
|
+
code: 201
|
185
|
+
message: Created
|
186
|
+
headers:
|
187
|
+
Cache-Control:
|
188
|
+
- max-age=0, private, must-revalidate
|
189
|
+
Content-Length:
|
190
|
+
- '292'
|
191
|
+
Content-Type:
|
192
|
+
- application/json; charset=utf-8
|
193
|
+
Date:
|
194
|
+
- Mon, 01 Nov 2021 23:08:31 GMT
|
195
|
+
Location:
|
196
|
+
- "/rest/events/d1919c58-4cf9-41e5-b9f8-f79c9cf58ef2"
|
197
|
+
Server:
|
198
|
+
- Cowboy
|
199
|
+
X-Request-Id:
|
200
|
+
- FrOOz3RteBsdfhMAAADG
|
201
|
+
body:
|
202
|
+
encoding: UTF-8
|
203
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"d1919c58-4cf9-41e5-b9f8-f79c9cf58ef2","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:08:31Z"}}'
|
204
|
+
recorded_at: Mon, 01 Nov 2021 23:08:31 GMT
|
205
|
+
- request:
|
206
|
+
method: post
|
207
|
+
uri: http://localhost:4000/rest/events
|
208
|
+
body:
|
209
|
+
encoding: UTF-8
|
210
|
+
string: '{"scheduled_for":"2021-11-02 01:08:52 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
211
|
+
body","endpoint":"https://api.fake-site.com"}'
|
212
|
+
headers:
|
213
|
+
Accept-Encoding:
|
214
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
215
|
+
Accept:
|
216
|
+
- "*/*"
|
217
|
+
User-Agent:
|
218
|
+
- Ruby
|
219
|
+
Authorization:
|
220
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
221
|
+
Content-Type:
|
222
|
+
- application/json
|
223
|
+
response:
|
224
|
+
status:
|
225
|
+
code: 201
|
226
|
+
message: Created
|
227
|
+
headers:
|
228
|
+
Cache-Control:
|
229
|
+
- max-age=0, private, must-revalidate
|
230
|
+
Content-Length:
|
231
|
+
- '292'
|
232
|
+
Content-Type:
|
233
|
+
- application/json; charset=utf-8
|
234
|
+
Date:
|
235
|
+
- Mon, 01 Nov 2021 23:08:52 GMT
|
236
|
+
Location:
|
237
|
+
- "/rest/events/e6e28a5f-23e5-43fa-939d-c103c5065f27"
|
238
|
+
Server:
|
239
|
+
- Cowboy
|
240
|
+
X-Request-Id:
|
241
|
+
- FrOO1HFT-oLVzCkAAAFG
|
242
|
+
body:
|
243
|
+
encoding: UTF-8
|
244
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"e6e28a5f-23e5-43fa-939d-c103c5065f27","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:08:52Z"}}'
|
245
|
+
recorded_at: Mon, 01 Nov 2021 23:08:52 GMT
|
246
|
+
- request:
|
247
|
+
method: post
|
248
|
+
uri: http://localhost:4000/rest/events
|
249
|
+
body:
|
250
|
+
encoding: UTF-8
|
251
|
+
string: '{"scheduled_for":"2021-11-02 01:09:28 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
252
|
+
body","endpoint":"https://api.fake-site.com"}'
|
253
|
+
headers:
|
254
|
+
Accept-Encoding:
|
255
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
256
|
+
Accept:
|
257
|
+
- "*/*"
|
258
|
+
User-Agent:
|
259
|
+
- Ruby
|
260
|
+
Authorization:
|
261
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
262
|
+
Content-Type:
|
263
|
+
- application/json
|
264
|
+
response:
|
265
|
+
status:
|
266
|
+
code: 201
|
267
|
+
message: Created
|
268
|
+
headers:
|
269
|
+
Cache-Control:
|
270
|
+
- max-age=0, private, must-revalidate
|
271
|
+
Content-Length:
|
272
|
+
- '292'
|
273
|
+
Content-Type:
|
274
|
+
- application/json; charset=utf-8
|
275
|
+
Date:
|
276
|
+
- Mon, 01 Nov 2021 23:09:28 GMT
|
277
|
+
Location:
|
278
|
+
- "/rest/events/eb8c5939-406e-40c4-96a0-f05ee7280ad5"
|
279
|
+
Server:
|
280
|
+
- Cowboy
|
281
|
+
X-Request-Id:
|
282
|
+
- FrOO3Mx1U2RudXwAAABI
|
283
|
+
body:
|
284
|
+
encoding: UTF-8
|
285
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"eb8c5939-406e-40c4-96a0-f05ee7280ad5","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:09:28Z"}}'
|
286
|
+
recorded_at: Mon, 01 Nov 2021 23:09:28 GMT
|
287
|
+
- request:
|
288
|
+
method: post
|
289
|
+
uri: http://localhost:4000/rest/events
|
290
|
+
body:
|
291
|
+
encoding: UTF-8
|
292
|
+
string: '{"scheduled_for":"2021-11-02 01:10:10 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
293
|
+
body","endpoint":"https://api.fake-site.com"}'
|
294
|
+
headers:
|
295
|
+
Accept-Encoding:
|
296
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
297
|
+
Accept:
|
298
|
+
- "*/*"
|
299
|
+
User-Agent:
|
300
|
+
- Ruby
|
301
|
+
Authorization:
|
302
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
303
|
+
Content-Type:
|
304
|
+
- application/json
|
305
|
+
response:
|
306
|
+
status:
|
307
|
+
code: 201
|
308
|
+
message: Created
|
309
|
+
headers:
|
310
|
+
Cache-Control:
|
311
|
+
- max-age=0, private, must-revalidate
|
312
|
+
Content-Length:
|
313
|
+
- '292'
|
314
|
+
Content-Type:
|
315
|
+
- application/json; charset=utf-8
|
316
|
+
Date:
|
317
|
+
- Mon, 01 Nov 2021 23:10:09 GMT
|
318
|
+
Location:
|
319
|
+
- "/rest/events/7f51d158-07f3-4d66-b818-97b7367e10a8"
|
320
|
+
Server:
|
321
|
+
- Cowboy
|
322
|
+
X-Request-Id:
|
323
|
+
- FrOO5niZj6ksFBUAAAAK
|
324
|
+
body:
|
325
|
+
encoding: UTF-8
|
326
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"7f51d158-07f3-4d66-b818-97b7367e10a8","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:10:10Z"}}'
|
327
|
+
recorded_at: Mon, 01 Nov 2021 23:10:10 GMT
|
328
|
+
- request:
|
329
|
+
method: post
|
330
|
+
uri: http://localhost:4000/rest/events
|
331
|
+
body:
|
332
|
+
encoding: UTF-8
|
333
|
+
string: '{"scheduled_for":"2021-11-02 01:10:45 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
334
|
+
body","endpoint":"https://api.fake-site.com"}'
|
335
|
+
headers:
|
336
|
+
Accept-Encoding:
|
337
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
338
|
+
Accept:
|
339
|
+
- "*/*"
|
340
|
+
User-Agent:
|
341
|
+
- Ruby
|
342
|
+
Authorization:
|
343
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
344
|
+
Content-Type:
|
345
|
+
- application/json
|
346
|
+
response:
|
347
|
+
status:
|
348
|
+
code: 201
|
349
|
+
message: Created
|
350
|
+
headers:
|
351
|
+
Cache-Control:
|
352
|
+
- max-age=0, private, must-revalidate
|
353
|
+
Content-Length:
|
354
|
+
- '292'
|
355
|
+
Content-Type:
|
356
|
+
- application/json; charset=utf-8
|
357
|
+
Date:
|
358
|
+
- Mon, 01 Nov 2021 23:10:44 GMT
|
359
|
+
Location:
|
360
|
+
- "/rest/events/14ab2fc7-a5d5-44e7-8650-1da77e653046"
|
361
|
+
Server:
|
362
|
+
- Cowboy
|
363
|
+
X-Request-Id:
|
364
|
+
- FrOO7p7R1XAxsQ4AAAFH
|
365
|
+
body:
|
366
|
+
encoding: UTF-8
|
367
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"14ab2fc7-a5d5-44e7-8650-1da77e653046","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:10:45Z"}}'
|
368
|
+
recorded_at: Mon, 01 Nov 2021 23:10:45 GMT
|
44
369
|
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:4000/rest/events
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"scheduled_for":"2021-11-02 01:12:00 +0100","method":"post","headers":{"Random-Header":"Something"},"body":"Random
|
9
|
+
body","endpoint":"https://api.fake-site.com"}'
|
10
|
+
headers:
|
11
|
+
Accept-Encoding:
|
12
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
13
|
+
Accept:
|
14
|
+
- "*/*"
|
15
|
+
User-Agent:
|
16
|
+
- Ruby
|
17
|
+
Authorization:
|
18
|
+
- Bearer 0u9dmuz_uxQf4bD_rYzltCWA8hrUjvxQQ-ILWFppj7sfSfkjoNqbCX_oqtJ1ska3GaYACb25Ef-uYcbITTYJbA==
|
19
|
+
Content-Type:
|
20
|
+
- application/json
|
21
|
+
response:
|
22
|
+
status:
|
23
|
+
code: 201
|
24
|
+
message: Created
|
25
|
+
headers:
|
26
|
+
Cache-Control:
|
27
|
+
- max-age=0, private, must-revalidate
|
28
|
+
Content-Length:
|
29
|
+
- '292'
|
30
|
+
Content-Type:
|
31
|
+
- application/json; charset=utf-8
|
32
|
+
Date:
|
33
|
+
- Mon, 01 Nov 2021 23:11:59 GMT
|
34
|
+
Location:
|
35
|
+
- "/rest/events/a350e6b1-7beb-4948-80ec-d1fbeaaf0add"
|
36
|
+
Server:
|
37
|
+
- Cowboy
|
38
|
+
X-Request-Id:
|
39
|
+
- FrOPACKU-RkX8pIAAADE
|
40
|
+
body:
|
41
|
+
encoding: UTF-8
|
42
|
+
string: '{"data":{"body":"Random body","dispatched_at":null,"endpoint":"https://api.fake-site.com","enqueued_at":null,"headers":"{\"Random-Header\":\"Something\"}","id":"a350e6b1-7beb-4948-80ec-d1fbeaaf0add","locked_at":null,"method":"post","origin":"rest_api","scheduled_for":"2021-11-02T00:12:00Z"}}'
|
43
|
+
recorded_at: Mon, 01 Nov 2021 23:12:00 GMT
|
44
|
+
recorded_with: VCR 6.0.0
|
data/lib/bloodbath/event.rb
CHANGED
@@ -3,21 +3,31 @@ require "net/http"
|
|
3
3
|
require "pry"
|
4
4
|
require "json"
|
5
5
|
|
6
|
+
require_relative "utils/threading"
|
7
|
+
|
6
8
|
module Bloodbath
|
7
9
|
module Adapters
|
8
10
|
class Rest
|
9
|
-
|
11
|
+
include Bloodbath::Utils::Threading
|
12
|
+
|
13
|
+
attr_reader :method, :endpoint, :body, :options, :config
|
10
14
|
|
11
|
-
def initialize(method:, endpoint:, body: nil, config: Bloodbath.config)
|
15
|
+
def initialize(method:, endpoint:, body: nil, options:, config: Bloodbath.config)
|
12
16
|
@method = method
|
13
17
|
@endpoint = endpoint
|
14
18
|
@body = body
|
19
|
+
@options = options
|
15
20
|
@config = config
|
16
21
|
end
|
17
22
|
|
18
23
|
def perform
|
19
24
|
check_api_key
|
20
|
-
|
25
|
+
|
26
|
+
if options[:wait_for_response]
|
27
|
+
synchronous_call_with_response
|
28
|
+
else
|
29
|
+
asynchronously { synchronous_call_with_response }
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
private
|
@@ -26,7 +36,11 @@ module Bloodbath
|
|
26
36
|
raise Bloodbath::Error, "Please set your API key through Bloodbath.api_key = 'my-api-key'" unless config.api_key
|
27
37
|
end
|
28
38
|
|
29
|
-
def
|
39
|
+
def asynchronously
|
40
|
+
threading { yield }
|
41
|
+
end
|
42
|
+
|
43
|
+
def synchronous_call_with_response
|
30
44
|
http = Net::HTTP.new(uri.host, uri.port)
|
31
45
|
http.use_ssl = true if uri.instance_of?(URI::HTTPS)
|
32
46
|
|
@@ -68,30 +82,50 @@ module Bloodbath
|
|
68
82
|
end
|
69
83
|
end
|
70
84
|
|
85
|
+
# when we want to add specific Ruby library options we instanciate what we want
|
86
|
+
# instead of going with Event.schedule we do Event.new(my_option: true).schedule
|
87
|
+
# this is to manage the transition to go class first while adding the options
|
71
88
|
module Bloodbath
|
72
89
|
class Event
|
73
90
|
class << self
|
74
|
-
def
|
75
|
-
|
91
|
+
def method_missing(method_name, args = {}, &block)
|
92
|
+
return new.send(method_name, &block) if args == {}
|
93
|
+
new.send(method_name, args, &block)
|
76
94
|
end
|
77
95
|
|
78
|
-
def
|
79
|
-
|
96
|
+
def respond_to_missing?(method_name, include_private = false)
|
97
|
+
super
|
80
98
|
end
|
99
|
+
end
|
81
100
|
|
82
|
-
|
83
|
-
adapter.new(method: :get, endpoint: "/events/#{id}").perform
|
84
|
-
end
|
101
|
+
attr_reader :options
|
85
102
|
|
86
|
-
|
87
|
-
|
88
|
-
|
103
|
+
def initialize(wait_for_response: true)
|
104
|
+
@options = {
|
105
|
+
wait_for_response: wait_for_response,
|
106
|
+
}
|
107
|
+
end
|
89
108
|
|
90
|
-
|
109
|
+
def schedule(args)
|
110
|
+
adapter.new(method: :post, endpoint: "/events", body: args, options: options).perform
|
111
|
+
end
|
91
112
|
|
92
|
-
|
93
|
-
|
94
|
-
|
113
|
+
def list
|
114
|
+
adapter.new(method: :get, endpoint: "/events", options: options).perform
|
115
|
+
end
|
116
|
+
|
117
|
+
def find(id)
|
118
|
+
adapter.new(method: :get, endpoint: "/events/#{id}", options: options).perform
|
119
|
+
end
|
120
|
+
|
121
|
+
def cancel(id)
|
122
|
+
adapter.new(method: :delete, endpoint: "/events/#{id}", options: options).perform
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
def adapter
|
128
|
+
Bloodbath::Adapters::Rest
|
95
129
|
end
|
96
130
|
end
|
97
131
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rubocop:disable Style/ClassVars
|
3
|
+
module Bloodbath
|
4
|
+
module Utils
|
5
|
+
module Threading
|
6
|
+
MAX_ACTIVE_THREADS = 10
|
7
|
+
@@threads = []
|
8
|
+
@@count = 0
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def join_all_threads
|
12
|
+
@@threads.each(&:join).tap do
|
13
|
+
@@count += @@threads.size
|
14
|
+
@@threads = []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
at_exit do
|
20
|
+
join_all_threads
|
21
|
+
end
|
22
|
+
|
23
|
+
def threading
|
24
|
+
thread = Thread.new { yield }
|
25
|
+
to_active_threads(thread)
|
26
|
+
|
27
|
+
Utils::Threading.join_all_threads if active_threads.size >= MAX_ACTIVE_THREADS
|
28
|
+
thread
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def to_active_threads(thread)
|
34
|
+
@@threads << thread
|
35
|
+
end
|
36
|
+
|
37
|
+
def active_threads
|
38
|
+
@@threads
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/bloodbath/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bloodbath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Schaffner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -159,12 +159,17 @@ files:
|
|
159
159
|
- bin/setup
|
160
160
|
- bloodbath.gemspec
|
161
161
|
- fixtures/vcr_cassettes/Bloodbath_Event/_cancel/1_4_1.yml
|
162
|
+
- fixtures/vcr_cassettes/Bloodbath_Event/_cancel/_cancel/1_4_2_1.yml
|
162
163
|
- fixtures/vcr_cassettes/Bloodbath_Event/_find/1_3_1.yml
|
164
|
+
- fixtures/vcr_cassettes/Bloodbath_Event/_find/_find/1_3_2_1.yml
|
163
165
|
- fixtures/vcr_cassettes/Bloodbath_Event/_list/1_2_1.yml
|
166
|
+
- fixtures/vcr_cassettes/Bloodbath_Event/_list/_list/1_2_1_1.yml
|
164
167
|
- fixtures/vcr_cassettes/Bloodbath_Event/_schedule/1_1_1.yml
|
168
|
+
- fixtures/vcr_cassettes/Bloodbath_Event/_schedule/_schedule/1_1_2_1.yml
|
165
169
|
- lib/bloodbath.rb
|
166
170
|
- lib/bloodbath/configuration.rb
|
167
171
|
- lib/bloodbath/event.rb
|
172
|
+
- lib/bloodbath/utils/threading.rb
|
168
173
|
- lib/bloodbath/version.rb
|
169
174
|
homepage: https://bloodbath.io
|
170
175
|
licenses: []
|
@@ -188,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
193
|
- !ruby/object:Gem::Version
|
189
194
|
version: '0'
|
190
195
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.1.4
|
192
197
|
signing_key:
|
193
198
|
specification_version: 4
|
194
199
|
summary: The Bloodbath Ruby library provides convenient access to the Bloodbath APIfrom
|