event_store_subscriptions 1.2.0.pre.beta → 2.0.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
  SHA256:
3
- metadata.gz: d4c9670cef56ce7f40e1cd718b0c4c7bd5434c4ac9f08a2dfdaed67b3f4fe5e7
4
- data.tar.gz: bb5fba8a703d5638b6b13e239afb5e30e4b53a84ac2bdd61be196dc3472f0e66
3
+ metadata.gz: 75032960fc3a03266a49977c0ed95b97d1839a3692d2c74523d8c15317696469
4
+ data.tar.gz: e06b3307204c5ac332745e4703377b1ab262a6cd209c8eff63695fcfdc543988
5
5
  SHA512:
6
- metadata.gz: a5438125c4d0e13b7533b14cab8d194994f5fbab0bcb5f076c611313e163938950a6f8b28981dcc01444699a119881e4b71e1951ef4e97d3931e40b4fa94a855
7
- data.tar.gz: d87f4a85798d5ba05e90bf0862fa6949683278a4b45da7bf0ec59f0c5f4ac6dc7c08a8c23a36cfcafdb57ec75f0bab4ce1d1942385237067e8f0e80b9f3d175b
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 |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.0-beta"
4
+ VERSION = "2.0.0"
5
5
  end
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: 1.2.0.pre.beta
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: 2022-12-20 00:00:00.000000000 Z
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: 2.3.0.pre.beta2
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.pre.beta2
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,9 +106,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: 2.7.0
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">"
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 1.3.1
111
+ version: '0'
112
112
  requirements: []
113
113
  rubygems_version: 3.3.7
114
114
  signing_key: