event_store_client 0.2.4 → 0.2.5

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: cc9b9f123804c920a08c07937465ae04afcd971d784912099f06822725742901
4
- data.tar.gz: 0e5e5e7d863180a90fa20a6c6d1d2b8e76b479cb50489910af2327a33e0d2c7f
3
+ metadata.gz: daaf4a7e189d14224fa8b520345b9108f6c9c02316d57742d599b3fe5fb15e22
4
+ data.tar.gz: 9eb7350e33cd14b7e9aff5ed2d8cf313838b6fe1df739ba5c4348111f18ec323
5
5
  SHA512:
6
- metadata.gz: 04e46ab7a710fc53c7be0d22bbadd59e6a075495174b88447cb82f054de5dcfa02607a1bf7cc03392952bdabb6dffc68ec264575264bd1fb3a9d5ac32447caea
7
- data.tar.gz: 188cff27182fe3e6f83250c70a3a4a5cab9814b7ef1ce61a624af2bcd235d4cf950723e7551d8ec2612f64923b117592341ea4ada03fe44660c6f2f7713f05ce
6
+ metadata.gz: 803a1ac900741c28a9437135e48343d015eec4d55c3b1df5d536575bed13341f276aa85d24cb177cdf376284b1be7a0220b8b1bdde4bab558481b39f6ae930a4
7
+ data.tar.gz: 0fa249206dcbe74719fae1ba82e85de615d332cd82dc69d890154839e2fcccc7e6feb4269afc94fb9d46156816582a71a71afe364767c005e6ac101545c4b6e8
@@ -4,7 +4,7 @@ module EventStoreClient
4
4
  class Broker
5
5
  def call(subscriptions)
6
6
  subscriptions.each do |subscription|
7
- res = connection.consume_feed(subscription.stream, subscription.name) || []
7
+ res = connection.consume_feed(subscription.stream, subscription.name) || { events: [] }
8
8
  next if res[:events].none?
9
9
  res[:events].each { |event| subscription.subscriber.call(event) }
10
10
  connection.ack(res[:ack_uri])
@@ -9,8 +9,8 @@ module EventStoreClient
9
9
  attribute :id, Types::Strict::String.optional.default(nil)
10
10
  attribute :type, Types::Strict::String
11
11
  attribute :title, Types::Strict::String.optional.default(nil)
12
- attribute :data, Types::Strict::String.default('{}')
13
- attribute :metadata, Types::Strict::String.default('{}')
12
+ attribute :data, Types::Coercible::String.default('{}')
13
+ attribute :metadata, Types::Coercible::String.default('{}')
14
14
 
15
15
  private
16
16
 
@@ -3,6 +3,8 @@
3
3
  module Serializer
4
4
  module Json
5
5
  def self.deserialize(data)
6
+ return data if data.is_a?(Hash)
7
+
6
8
  JSON.parse(data)
7
9
  end
8
10
 
@@ -123,7 +123,7 @@ module EventStoreClient
123
123
  headers: headers
124
124
  )
125
125
 
126
- return [] if response.body || response.body.empty?
126
+ return { events: [] } if response.body || response.body.empty?
127
127
 
128
128
  body = JSON.parse(response.body)
129
129
 
@@ -13,7 +13,6 @@ module EventStoreClient
13
13
 
14
14
  def append_to_stream(stream_name, events, expected_version: nil) # rubocop:disable Lint/UnusedMethodArgument,Metrics/LineLength
15
15
  event_store[stream_name] = [] unless event_store.key?(stream_name)
16
-
17
16
  [events].flatten.each do |event|
18
17
  event_store[stream_name].unshift(
19
18
  'eventId' => event.id,
@@ -145,11 +144,12 @@ module EventStoreClient
145
144
  private
146
145
 
147
146
  def deserialize_event(entry)
147
+ data = (entry['data'].is_a?(Hash) ? entry['data'].to_json.presence : entry['data']) || '{}'
148
148
  event = EventStoreClient::Event.new(
149
149
  id: entry['eventId'],
150
150
  title: entry['title'],
151
151
  type: entry['eventType'],
152
- data: entry['data'] || '{}',
152
+ data: data,
153
153
  metadata: entry['isMetaData'] ? entry['metaData'] : '{}'
154
154
  )
155
155
 
@@ -27,7 +27,7 @@ module EventStoreClient
27
27
  def create_subscription(subscription)
28
28
  # store position somewhere.
29
29
  connection.join_streams(subscription.name, subscription.observed_streams)
30
- connection.subscribe_to_stream(subscription.stream, name: subscription.name)
30
+ connection.subscribe_to_stream(subscription.stream, subscription.name)
31
31
  end
32
32
 
33
33
  attr_reader :connection, :subscriptions, :service
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-schema