event_store_client 1.2.3 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f72e92a631da57d27b68c2ba2644a1a089f3cd60ef910151801afd5d74bb3f1
4
- data.tar.gz: c92a76c6955aec9296bd4cbf57d29584672dea95887c2d9e531238dd8adfe347
3
+ metadata.gz: 700f420a0fa9e3fb0352784f3bc0431cac18216130ba397897dfb77c98a4f7c6
4
+ data.tar.gz: e408f3a666dd7f1e95634591923bf8df51ce30c6b521cd9042072f551e5ff645
5
5
  SHA512:
6
- metadata.gz: 25e44c8b41e5c22e2b469e096db5789e6c2aad0b18bfb82283a0959ddf73860058a700095aaf614fb931722f6e7184b91c050516cc208b7bf72b11d4cb277023
7
- data.tar.gz: 00e87f69e1da44a28995c187397d42f19cbec0701120b6961a64f3e489c4a6c6598fcfc0701f5a2954a46019ea81b3efd0d7f17d07fb44af7ac514892adec2b9
6
+ metadata.gz: 2232248c19c04924effd9bab97271f5a0bf3e7b4cf4e56e5453fc32a27c56d587777239b48d0aafc026c265b1086691aa5e8c04e7863209d9bb1e07c046946e6
7
+ data.tar.gz: 2db191ee47dae6f22b5858ab85bde4d3129af6220f534d9b11e502150058c7211285afa2562aae70ae08877e21c8d2205c8d1400ec8365e10567e7c5295b7afc
@@ -44,7 +44,12 @@ module EventStoreClient
44
44
  end
45
45
 
46
46
  skip_decryption = options[:skip_decryption] || false
47
- events = read_stream(opts, skip_decryption)
47
+ events =
48
+ if options[:skip_deserialization]
49
+ read_stream_raw(opts)
50
+ else
51
+ read_stream(opts, skip_decryption)
52
+ end
48
53
  Success(events)
49
54
  rescue StreamNotFound
50
55
  Failure(:not_found)
@@ -64,6 +69,18 @@ module EventStoreClient
64
69
  raise GRPCUnavailableRetryFailed
65
70
  end
66
71
 
72
+ def read_stream_raw(options)
73
+ retries ||= 0
74
+ service.read(request.new(options: options), metadata: metadata).map do |res|
75
+ raise StreamNotFound if res.stream_not_found
76
+ res.event.event
77
+ end
78
+ rescue ::GRPC::Unavailable
79
+ sleep config.grpc_unavailable_retry_sleep
80
+ retry if (retries += 1) <= config.grpc_unavailable_retry_count
81
+ raise GRPCUnavailableRetryFailed
82
+ end
83
+
67
84
  def deserialize_event(entry, skip_decryption: false)
68
85
  data = (entry.data.nil? || entry.data.empty?) ? '{}' : entry.data
69
86
 
@@ -15,14 +15,16 @@ module EventStoreClient
15
15
  end
16
16
  end
17
17
 
18
- def initialize(**args)
19
- validation = schema.call(args[:data] || {})
18
+ def initialize(args = {})
19
+ validation = schema.call(args[:data] || {}) unless args[:skip_validation]
20
20
  @data = args.fetch(:data) { {} }
21
21
  @metadata = args.fetch(:metadata) { {} }.merge(
22
22
  'type' => self.class.name,
23
23
  'content-type' => content_type
24
24
  )
25
- @metadata.merge!('validation-errors' => validation.errors.to_h) if validation.errors.any?
25
+ if !args[:skip_validation] && validation.errors.any?
26
+ @metadata.merge!('validation-errors' => validation.errors.to_h)
27
+ end
26
28
  @type = args[:type] || self.class.name
27
29
  @title = args[:title]
28
30
  @id = args[:id]
@@ -23,6 +23,7 @@ module EventStoreClient
23
23
  EventStoreClient::DeserializedEvent
24
24
  end
25
25
  event_class.new(
26
+ skip_validation: true,
26
27
  id: event.id,
27
28
  type: event.type,
28
29
  title: event.title,
@@ -51,7 +51,7 @@ module EventStoreClient
51
51
 
52
52
  def deserialize(event, skip_decryption: false)
53
53
  metadata = serializer.deserialize(event.metadata)
54
- encryption_schema = serializer.deserialize(event.metadata)['encryption']
54
+ encryption_schema = metadata['encryption']
55
55
 
56
56
  decrypted_data =
57
57
  if skip_decryption
@@ -72,6 +72,7 @@ module EventStoreClient
72
72
  end
73
73
 
74
74
  event_class.new(
75
+ skip_validation: true,
75
76
  id: event.id,
76
77
  type: event.type,
77
78
  title: event.title,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '1.2.3'
4
+ VERSION = '1.3.0'
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: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable