event_store_subscriptions 1.2.1 → 2.0.1

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
  SHA256:
3
- metadata.gz: 747f22b34eb3c13214861ecea91f0cd5f45f084d69c32836bf0a11f5bb1a08be
4
- data.tar.gz: 3359b50c2afc2c8f2259ecc92fa205a3b2050443674974d80ad571a38846f6f9
3
+ metadata.gz: 7f0ea0e0a7d5583dffb1783e4c51d78e42e048ef64720f34ba338814f5a07978
4
+ data.tar.gz: 87e8be2b18a52d2d6bff4634320b6fd0223c57fb4967f7279e0ce4b43efef5b8
5
5
  SHA512:
6
- metadata.gz: fd709c13e351fa25cd262fb84f545bd54941133a3a66e4ab06f88f03f43fb3941b3da781a36f24393145e967bd80b3fa053f1513210db6567a02b216c6471e13
7
- data.tar.gz: 1488e70c63f602a20fa96491a0bb03fa633c37281ad9290d873188c30c5580373fbb902ef3d9e99a7b712a4da88a175b215237e3e501bce98427dc3c6c0feb28
6
+ metadata.gz: 1b76357f9782e7980498b2328d067afb2743e9f0ba6db73b196c2253c3d6792a7a461e05e488a02f0ccf711cb9864d27798100ab0d9a5e7c9ea9aa7ba69cc14d
7
+ data.tar.gz: d47c76a3a191f73c2d654eebd537ed7cc277a05acb4b285a99e0fcb4ae9ef2b27de6b70214bd4c17515b9bdf18e2d7e3272b69f50b176744a269687ae82a3d20
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 |resp|
39
- if resp.success?
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(resp)
54
- if resp.success?
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 |resp|
73
- if resp.success?
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 |resp|
88
- if resp.success?
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 { |r| p r })
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 |result|
95
+ proc do |raw_resp|
96
96
  Thread.current.exit unless state.running?
97
- original_result = result.success
98
- result =
97
+ event_or_raw_resp =
99
98
  EventStoreClient::GRPC::Shared::Streams::ProcessResponse.new(config: client.config).call(
100
- original_result,
99
+ raw_resp,
101
100
  *process_response_args
102
101
  )
103
- if result
104
- original_handler.call(result)
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(original_result)
106
+ position.update(raw_resp)
108
107
  end
109
108
  end
110
109
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreSubscriptions
4
- VERSION = "1.2.1"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store_subscriptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Dzyzenko
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
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: 2.3.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement