event_store_subscriptions 1.2.0 → 2.0.0
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/README.md +16 -32
- data/lib/event_store_subscriptions/subscription.rb +6 -7
- data/lib/event_store_subscriptions/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75032960fc3a03266a49977c0ed95b97d1839a3692d2c74523d8c15317696469
|
4
|
+
data.tar.gz: e06b3307204c5ac332745e4703377b1ab262a6cd209c8eff63695fcfdc543988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7531c9388bbe3da6d669775698e0c9885ca588827eeaea6089f947ce2654c309ce552eec3587466b7608a75e0b7f3b224bdfe56fc565ae95cdfd99f06afcf07
|
7
|
+
data.tar.gz: c18cc6d826c77acb5e2c37de289d264a1bd9cc879d86d7f85870771ebb8887edfde0d19915e5641518c5625bf5d1abc30ba110ff6f285c395b3d2c20427195b9
|
data/README.md
CHANGED
@@ -35,12 +35,8 @@ Use the `#create` method in order to subscribe to specific stream:
|
|
35
35
|
|
36
36
|
```ruby
|
37
37
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
38
|
-
handler = proc do |
|
39
|
-
|
40
|
-
do_something_with_resp(resp.success) # retrieve an event
|
41
|
-
else # resp.failure? => true
|
42
|
-
handle_failure(resp.failure)
|
43
|
-
end
|
38
|
+
handler = proc do |event|
|
39
|
+
# process event
|
44
40
|
end
|
45
41
|
subscriptions.create('some-stream', handler: handler)
|
46
42
|
subscriptions.listen_all
|
@@ -50,12 +46,8 @@ You may provide any object which responds to `#call` as a handler:
|
|
50
46
|
|
51
47
|
```ruby
|
52
48
|
class SomeStreamHandler
|
53
|
-
def call(
|
54
|
-
|
55
|
-
do_something_with_resp(resp.success) # retrieve an event
|
56
|
-
else # resp.failure? => true
|
57
|
-
handle_failure(resp.failure)
|
58
|
-
end
|
49
|
+
def call(event)
|
50
|
+
# process event
|
59
51
|
end
|
60
52
|
end
|
61
53
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
@@ -69,12 +61,8 @@ Use the `#create_for_all` method to subscribe to the all stream:
|
|
69
61
|
|
70
62
|
```ruby
|
71
63
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
72
|
-
handler = proc do |
|
73
|
-
|
74
|
-
do_something_with_resp(resp.success) # retrieve an event
|
75
|
-
else # resp.failure? => true
|
76
|
-
handle_failure(resp.failure)
|
77
|
-
end
|
64
|
+
handler = proc do |event|
|
65
|
+
# process event
|
78
66
|
end
|
79
67
|
subscriptions.create_for_all(handler: handler)
|
80
68
|
subscriptions.listen_all
|
@@ -84,12 +72,8 @@ You may also explicitly pass `"$all"` stream name to the `#create` method:
|
|
84
72
|
|
85
73
|
```ruby
|
86
74
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
87
|
-
handler = proc do |
|
88
|
-
|
89
|
-
do_something_with_resp(resp.success) # retrieve an event
|
90
|
-
else # resp.failure? => true
|
91
|
-
handle_failure(resp.failure)
|
92
|
-
end
|
75
|
+
handler = proc do |event|
|
76
|
+
# process event
|
93
77
|
end
|
94
78
|
subscriptions.create('$all', handler: handler)
|
95
79
|
subscriptions.listen_all
|
@@ -105,7 +89,7 @@ A handler registered to receive position updates of a specific stream is called
|
|
105
89
|
|
106
90
|
```ruby
|
107
91
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
108
|
-
subscription = subscriptions.create('some-stream', handler: proc { |
|
92
|
+
subscription = subscriptions.create('some-stream', handler: proc { |event| p event })
|
109
93
|
subscription.position.register_update_hook do |position|
|
110
94
|
puts "Current revision is #{position.revision}"
|
111
95
|
end
|
@@ -118,7 +102,7 @@ A handler registered to receive position updates of the `$all` stream is called
|
|
118
102
|
|
119
103
|
```ruby
|
120
104
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
121
|
-
subscription = subscriptions.create_for_all(handler: proc { |
|
105
|
+
subscription = subscriptions.create_for_all(handler: proc { |event| p event })
|
122
106
|
subscription.position.register_update_hook do |position|
|
123
107
|
puts "Current commit/prepare positions are #{position.commit_position}/#{position.prepare_position}"
|
124
108
|
end
|
@@ -133,7 +117,7 @@ Start watching over your subscriptions' collection:
|
|
133
117
|
|
134
118
|
```ruby
|
135
119
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
136
|
-
subscriptions.create_for_all(handler: proc { |
|
120
|
+
subscriptions.create_for_all(handler: proc { |event| p event })
|
137
121
|
EventStoreSubscriptions::WatchDog.watch(subscriptions)
|
138
122
|
subscriptions.listen_all
|
139
123
|
```
|
@@ -154,7 +138,7 @@ For single subscription:
|
|
154
138
|
|
155
139
|
```ruby
|
156
140
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
157
|
-
subscription = subscriptions.create_for_all(handler: proc { |
|
141
|
+
subscription = subscriptions.create_for_all(handler: proc { |event| p event })
|
158
142
|
subscription.listen
|
159
143
|
|
160
144
|
# Initiate Subscription shutdown
|
@@ -167,7 +151,7 @@ For the entire collection:
|
|
167
151
|
|
168
152
|
```ruby
|
169
153
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
170
|
-
subscriptions.create_for_all(handler: proc { |
|
154
|
+
subscriptions.create_for_all(handler: proc { |event| p event })
|
171
155
|
subscriptions.listen_all
|
172
156
|
|
173
157
|
# Initiate shutdown for each Subscription in the collection
|
@@ -194,7 +178,7 @@ You may want to gracefully shut down the process that handles the subscriptions.
|
|
194
178
|
|
195
179
|
```ruby
|
196
180
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
197
|
-
subscriptions.create_for_all(handler: proc { |
|
181
|
+
subscriptions.create_for_all(handler: proc { |event| p event })
|
198
182
|
watcher = EventStoreSubscriptions::WatchDog.watch(subscriptions)
|
199
183
|
subscriptions.listen_all
|
200
184
|
|
@@ -225,7 +209,7 @@ After you started listening your Subscriptions, you may want to monitor status o
|
|
225
209
|
|
226
210
|
```ruby
|
227
211
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
228
|
-
subscriptions.create_for_all(handler: proc { |
|
212
|
+
subscriptions.create_for_all(handler: proc { |event| p event })
|
229
213
|
watcher = EventStoreSubscriptions::WatchDog.watch(subscriptions)
|
230
214
|
subscriptions.listen_all
|
231
215
|
|
@@ -249,7 +233,7 @@ You may want to decide yourself whether `WhatchDog` should restart a `Subscripti
|
|
249
233
|
|
250
234
|
```ruby
|
251
235
|
subscriptions = EventStoreSubscriptions::Subscriptions.new(EventStoreClient.client)
|
252
|
-
subscriptions.create_for_all(handler: proc { |
|
236
|
+
subscriptions.create_for_all(handler: proc { |event| p event })
|
253
237
|
# Do not restart Subscription if its id is even
|
254
238
|
restart_terminator = proc { |sub| sub.__id__ % 2 == 0 }
|
255
239
|
EventStoreSubscriptions::WatchDog.watch(subscriptions, restart_terminator: restart_terminator)
|
@@ -92,19 +92,18 @@ module EventStoreSubscriptions
|
|
92
92
|
# @param original_handler [#call]
|
93
93
|
# @return [Proc]
|
94
94
|
def handler(original_handler)
|
95
|
-
proc do |
|
95
|
+
proc do |raw_resp|
|
96
96
|
Thread.current.exit unless state.running?
|
97
|
-
|
98
|
-
result =
|
97
|
+
event_or_raw_resp =
|
99
98
|
EventStoreClient::GRPC::Shared::Streams::ProcessResponse.new(config: client.config).call(
|
100
|
-
|
99
|
+
raw_resp,
|
101
100
|
*process_response_args
|
102
101
|
)
|
103
|
-
if
|
104
|
-
original_handler.call(
|
102
|
+
if event_or_raw_resp
|
103
|
+
original_handler.call(event_or_raw_resp)
|
105
104
|
statistic.events_processed += 1
|
106
105
|
end
|
107
|
-
position.update(
|
106
|
+
position.update(raw_resp)
|
108
107
|
end
|
109
108
|
end
|
110
109
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_store_subscriptions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Dzyzenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_store_client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|