artsy-eventservice 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +18 -0
- data/lib/artsy-eventservice/artsy/event_service.rb +1 -1
- data/lib/artsy-eventservice/presenters/events/base_event.rb +4 -0
- data/lib/artsy-eventservice/version.rb +1 -1
- data/spec/artsy-eventstream/artsy/event_service_spec.rb +2 -2
- data/spec/artsy-eventstream/presenters/events/base_event_spec.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2fc420aec74a16109d3473d71cb71bd2c1fbafd
|
4
|
+
data.tar.gz: eda0bb72a66fe5cdc85887ea8d3c0aa325d5bae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bf09515e7ed36508e0f0de94fa652ed91842418b3c79411748c8bf9affc5abad0795d15e2a6aea6b65ee6780e959a586da34d14cad0c4eea486b60fd882ca91
|
7
|
+
data.tar.gz: 96323a9511c6db2f81a1f2c5bde6a316b8e9740b43f1385f8698421a2079bbcce5eb73af576871baefcbc654dd534a092f3287be7471bf9e4b722d6e1ac90ce6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -59,10 +59,28 @@ Call `post_event` with proper `topic` and `event`:
|
|
59
59
|
Artsy::EventService.post_event(topic: 'testing', event: event_model)
|
60
60
|
```
|
61
61
|
|
62
|
+
# How to pick topic and routing key?
|
63
|
+
Think of topic as high level business area. From consumer perspective there will be one connection per topic, consumer can decide to filter events they want to receive in that topic based on `routing_key` they listening on. For `topic` use plural names.
|
64
|
+
|
65
|
+
We recommend to use following `routing_key` strategy:
|
66
|
+
`<model_name>.<verb>`.
|
67
|
+
|
68
|
+
Few examples:
|
69
|
+
- Topic: `conversations`, routing key: `message.sent`
|
70
|
+
- Topic: `conversations`, routing key: `conversation.created`
|
71
|
+
- Topic: `conversations`, routing key: `conversation.dismissed`
|
72
|
+
- Topic: `invoices`, routing key: `invoice.paid`
|
73
|
+
- Topic: `invoices`, routing key: `merchant_account.created`
|
74
|
+
|
75
|
+
`BaseEvent` provides `routing_key` method by default which follows the same pattern mention above, you can override `routing_key` when calling `post_event`.
|
62
76
|
|
63
77
|
### Update to Version 1.0
|
64
78
|
In previous versions this gem was using Environment variables for configuration. On version 1.0, configuration step is now mandatory and it will no longer read environment variables directly. Make sure to go to configuration step.
|
65
79
|
|
80
|
+
### Update to Version 1.0.3
|
81
|
+
Since this version we've updated `routing_key` to default to `<event object class name>.<event.verb>`. This means if your consumers were listening on `verb` routing key, now they need to update to include object's class name.
|
82
|
+
You can always override this feature by passing in `routing_key` to `post_event`.
|
83
|
+
|
66
84
|
# Contributing
|
67
85
|
|
68
86
|
* Fork the project.
|
@@ -4,7 +4,7 @@ module Artsy
|
|
4
4
|
module EventService
|
5
5
|
def self.post_event(topic:, event:, routing_key: nil)
|
6
6
|
return unless event_stream_enabled?
|
7
|
-
Publisher.publish(topic: topic, event: event, routing_key: routing_key)
|
7
|
+
Publisher.publish(topic: topic, event: event, routing_key: routing_key || event.routing_key)
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.consume(**args)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Artsy::EventService do
|
5
|
-
let(:event) { double('event', topic: 'foo', verb: 'bar') }
|
5
|
+
let(:event) { double('event', topic: 'foo', verb: 'bar', routing_key: 'test.passed') }
|
6
6
|
|
7
7
|
context 'event stream disabled' do
|
8
8
|
before do
|
@@ -22,7 +22,7 @@ describe Artsy::EventService do
|
|
22
22
|
end
|
23
23
|
describe '.post_event' do
|
24
24
|
it 'calls publish with proper params' do
|
25
|
-
expect(Artsy::EventService::Publisher).to receive(:publish).with(topic: 'test', event: event, routing_key:
|
25
|
+
expect(Artsy::EventService::Publisher).to receive(:publish).with(topic: 'test', event: event, routing_key: 'test.passed')
|
26
26
|
|
27
27
|
Artsy::EventService.post_event(topic: 'test', event: event)
|
28
28
|
end
|