phobos_db_checkpoint 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b29e206cb7135f08b91717795503156869f4b7f
4
- data.tar.gz: e5e38ea02d946d15df776e139de72943e85cbefc
3
+ metadata.gz: f2b492fa71a95e8304f837094421494f8a441a1a
4
+ data.tar.gz: 6470c1c13a9ab979cac8f228a725d5782e50f027
5
5
  SHA512:
6
- metadata.gz: a01c09788822ac5ecf0f11d412777b9a29274645ad46805ebb972da9e6469afec76402ea364d03bd61011ccab1d35912d4986dfa83550133eee757adc88c3125
7
- data.tar.gz: f76968bd632cd8a0a5f98a39458d9d07af98a0cbba1c6596b9a015c7fb37e8821ac407cba2d6ec8e70b8f42f0f31c27d2095376f71a472772b4203b5bf05507c
6
+ metadata.gz: f2327f3693b35fb330f9af48a878dd7e825e24eadb7f43627ad348c0c48f0f9df2c72c10933bf95298faf99e02a18220348647126073db1add6e3f8705b0b1cb
7
+ data.tar.gz: 5cf8e5153d09340f01aab345b55ad07891ea055a8946648f503b382dd8b67adaed0ad8ff6a626ee32d8056ab5047bf55909fbcb154a4982702741bcf20924651
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## 1.1.0 (2017-02-28)
8
+
9
+ - [feature] Add end point for fetching individual failures
10
+
7
11
  ## 1.0.0 (2017-02-24)
8
12
 
9
13
  - [feature] Introduce failures and failure handling in Handler. Add failures to the events API
data/README.md CHANGED
@@ -141,7 +141,7 @@ The control is based on `payload` and `exception`:
141
141
  class MyHandler
142
142
  include PhobosDBCheckpoint::Handler
143
143
 
144
- def retry_consume?(event, event_metadata, exception)
144
+ def self.retry_consume?(event, event_metadata, exception)
145
145
  event_metadata[:retry_count] <= MyApp.config.max_retries
146
146
  end
147
147
  end
@@ -196,6 +196,32 @@ $ phobos_db_checkpoint init_events_api
196
196
  Start the API with: `rackup config.ru`
197
197
  ```
198
198
 
199
+ The available routes are:
200
+
201
+ * GET `/ping`
202
+ * GET `/v1/events/:id`
203
+ * GET `/v1/events` This route accepts the following params:
204
+ * `limit`, default: 20
205
+ * `offset`, default: 0
206
+ * `entity_id`
207
+ * `topic`
208
+ * `group_id`
209
+ * `event_type`
210
+ * POST `/v1/events/:id/retry`
211
+ * GET `/v1/failures/:id`
212
+ * GET `/v1/failures` This route accepts the following params:
213
+ * `limit`, default: 20
214
+ * `offset`, default: 0
215
+ * `entity_id`
216
+ * `topic`
217
+ * `group_id`
218
+ * `event_type`
219
+ * POST `/v1/failures/:id/retry`
220
+
221
+ #### Events endpoint
222
+
223
+ Sample output for event:
224
+
199
225
  ```sh
200
226
  $ curl "http://localhost:9292/v1/events/1"
201
227
  # {
@@ -207,22 +233,43 @@ $ curl "http://localhost:9292/v1/events/1"
207
233
  # "event_type": "create",
208
234
  # "event_version": "v1",
209
235
  # "checksum": "188773471ec0f898fd81d272760a027f",
210
- # "payload": "{\"a\":\"b\"}"
236
+ # "payload": {
237
+ # "a": "b"
238
+ # }
211
239
  # }
212
240
  ```
213
241
 
214
- The available routes are:
242
+ #### Failures endpoint
215
243
 
216
- * GET `/ping`
217
- * GET `/v1/events/:id`
218
- * GET `/v1/events` This route accepts the following params:
219
- * `limit`, default: 20
220
- * `offset`, default: 0
221
- * `entity_id`
222
- * `topic`
223
- * `group_id`
224
- * `event_type`
225
- * POST `/v1/events/:id/retry`
244
+ Sample output for failure:
245
+
246
+ ```sh
247
+ $ curl "http://localhost:9292/v1/failures/1"
248
+ # {
249
+ # "id": 1,
250
+ # "created_at": "2017-02-28T07:53:21.790Z",
251
+ # "topic": "test-partitions",
252
+ # "group_id": "test-checkpoint-1",
253
+ # "entity_id": "32de6e8e-4317-4ff7-bbce-aa4a6d41294a",
254
+ # "event_time": "2016-08-10T07:07:58.907Z",
255
+ # "event_type": "test-event-type",
256
+ # "event_version": "v1",
257
+ # "checksum": "12c9e42bca2728fc8193c87979bfe510",
258
+ # "payload": {
259
+ # "a": "b"
260
+ # },
261
+ # "metadata": {
262
+ # "c": "d"
263
+ # },
264
+ # "error_class": "Faraday::ConnectionFailed",
265
+ # "error_message": "Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \"localhost\" port 9200)",
266
+ # "error_backtrace": [
267
+ # "/Users/mathias.klippinge/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'",
268
+ # "/Users/mathias.klippinge/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'",
269
+ # "..."
270
+ # ]
271
+ # }
272
+ ```
226
273
 
227
274
  ### <a name="instrumentation"></a> Instrumentation
228
275
 
@@ -18,7 +18,8 @@ module PhobosDBCheckpoint
18
18
  error ActiveRecord::RecordNotFound do
19
19
  content_type :json
20
20
  status 404
21
- { error: true, message: 'event not found' }.to_json
21
+ type = env['sinatra.route'].match(/\/.+\/(.+)\/:/)[1].chop
22
+ { error: true, message: "#{type} not found" }.to_json
22
23
  end
23
24
 
24
25
  error StandardError do
@@ -99,6 +100,13 @@ module PhobosDBCheckpoint
99
100
  .to_json
100
101
  end
101
102
 
103
+ get "/#{VERSION}/failures/:id" do
104
+ content_type :json
105
+ PhobosDBCheckpoint::Failure
106
+ .find(params['id'])
107
+ .to_json
108
+ end
109
+
102
110
  post "/#{VERSION}/failures/:id/retry" do
103
111
  content_type :json
104
112
  failure = PhobosDBCheckpoint::Failure.find(params['id'])
@@ -1,3 +1,3 @@
1
1
  module PhobosDBCheckpoint
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phobos_db_checkpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Túlio Ornelas
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-02-24 00:00:00.000000000 Z
16
+ date: 2017-02-28 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler