event_store_client 0.2.8 → 1.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 +29 -37
- data/lib/event_store_client.rb +0 -2
- data/lib/event_store_client/adapters/grpc.rb +21 -0
- data/lib/event_store_client/adapters/grpc/Protos/cluster.proto +149 -0
- data/lib/event_store_client/adapters/grpc/Protos/gossip.proto +44 -0
- data/lib/event_store_client/adapters/grpc/Protos/operations.proto +45 -0
- data/lib/event_store_client/adapters/grpc/Protos/persistent.proto +180 -0
- data/lib/event_store_client/adapters/grpc/Protos/projections.proto +174 -0
- data/lib/event_store_client/adapters/grpc/Protos/shared.proto +22 -0
- data/lib/event_store_client/adapters/grpc/Protos/streams.proto +242 -0
- data/lib/event_store_client/adapters/grpc/Protos/users.proto +119 -0
- data/lib/event_store_client/adapters/grpc/client.rb +119 -0
- data/lib/event_store_client/adapters/grpc/command_registrar.rb +32 -0
- data/lib/event_store_client/adapters/grpc/commands/command.rb +43 -0
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/create.rb +46 -0
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/delete.rb +34 -0
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/read.rb +66 -0
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/settings_schema.rb +38 -0
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/update.rb +48 -0
- data/lib/event_store_client/adapters/grpc/commands/projections/create.rb +45 -0
- data/lib/event_store_client/adapters/grpc/commands/projections/delete.rb +34 -0
- data/lib/event_store_client/adapters/grpc/commands/projections/update.rb +42 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/append.rb +57 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/delete.rb +35 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/link_to.rb +53 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/read.rb +80 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/read_all.rb +43 -0
- data/lib/event_store_client/adapters/grpc/commands/streams/tombstone.rb +35 -0
- data/lib/event_store_client/adapters/grpc/connection.rb +50 -0
- data/lib/event_store_client/adapters/grpc/generated/cluster_pb.rb +140 -0
- data/lib/event_store_client/adapters/grpc/generated/cluster_services_pb.rb +46 -0
- data/lib/event_store_client/adapters/grpc/generated/gossip_pb.rb +53 -0
- data/lib/event_store_client/adapters/grpc/generated/gossip_services_pb.rb +26 -0
- data/lib/event_store_client/adapters/grpc/generated/operations_pb.rb +49 -0
- data/lib/event_store_client/adapters/grpc/generated/operations_services_pb.rb +31 -0
- data/lib/event_store_client/adapters/grpc/generated/persistent_pb.rb +213 -0
- data/lib/event_store_client/adapters/grpc/generated/persistent_services_pb.rb +29 -0
- data/lib/event_store_client/adapters/grpc/generated/projections_pb.rb +193 -0
- data/lib/event_store_client/adapters/grpc/generated/projections_services_pb.rb +34 -0
- data/lib/event_store_client/adapters/grpc/generated/shared_pb.rb +35 -0
- data/lib/event_store_client/adapters/grpc/generated/streams_pb.rb +283 -0
- data/lib/event_store_client/adapters/grpc/generated/streams_services_pb.rb +29 -0
- data/lib/event_store_client/adapters/grpc/generated/users_pb.rb +126 -0
- data/lib/event_store_client/adapters/grpc/generated/users_services_pb.rb +33 -0
- data/lib/event_store_client/adapters/http.rb +16 -0
- data/lib/event_store_client/adapters/http/README.md +16 -0
- data/lib/event_store_client/adapters/http/client.rb +160 -0
- data/lib/event_store_client/adapters/http/commands/command.rb +27 -0
- data/lib/event_store_client/adapters/http/commands/persistent_subscriptions/ack.rb +15 -0
- data/lib/event_store_client/adapters/http/commands/persistent_subscriptions/create.rb +31 -0
- data/lib/event_store_client/adapters/http/commands/persistent_subscriptions/read.rb +57 -0
- data/lib/event_store_client/adapters/http/commands/projections/create.rb +30 -0
- data/lib/event_store_client/adapters/http/commands/streams/append.rb +49 -0
- data/lib/event_store_client/adapters/http/commands/streams/delete.rb +16 -0
- data/lib/event_store_client/adapters/http/commands/streams/link_to.rb +49 -0
- data/lib/event_store_client/adapters/http/commands/streams/read.rb +53 -0
- data/lib/event_store_client/adapters/http/commands/streams/tombstone.rb +17 -0
- data/lib/event_store_client/adapters/http/connection.rb +46 -0
- data/lib/event_store_client/adapters/http/request_method.rb +28 -0
- data/lib/event_store_client/adapters/in_memory.rb +139 -0
- data/lib/event_store_client/broker.rb +16 -5
- data/lib/event_store_client/client.rb +17 -69
- data/lib/event_store_client/configuration.rb +28 -14
- data/lib/event_store_client/data_decryptor.rb +13 -8
- data/lib/event_store_client/data_encryptor.rb +7 -6
- data/lib/event_store_client/deserialized_event.rb +4 -1
- data/lib/event_store_client/event.rb +2 -2
- data/lib/event_store_client/mapper/default.rb +0 -1
- data/lib/event_store_client/serializer/json.rb +2 -0
- data/lib/event_store_client/subscriptions.rb +4 -13
- data/lib/event_store_client/types.rb +3 -1
- data/lib/event_store_client/value_objects/read_direction.rb +43 -0
- data/lib/event_store_client/version.rb +1 -1
- metadata +97 -15
- data/lib/event_store_client/store_adapter.rb +0 -10
- data/lib/event_store_client/store_adapter/api/client.rb +0 -224
- data/lib/event_store_client/store_adapter/api/connection.rb +0 -43
- data/lib/event_store_client/store_adapter/api/request_method.rb +0 -30
- data/lib/event_store_client/store_adapter/in_memory.rb +0 -160
|
@@ -2,21 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
module EventStoreClient
|
|
4
4
|
class Broker
|
|
5
|
-
|
|
5
|
+
include Configuration
|
|
6
|
+
|
|
7
|
+
# Distributes known subscriptions to multiple threads
|
|
8
|
+
# @param [EventStoreClient::Subscriptions]
|
|
9
|
+
# @param wait [Boolean] (Optional) Controls if broker shold block
|
|
10
|
+
# main app process (useful for debugging)
|
|
11
|
+
#
|
|
12
|
+
def call(subscriptions, wait: false)
|
|
6
13
|
subscriptions.each do |subscription|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
threads << Thread.new do
|
|
15
|
+
connection.listen(subscription, options: { interval: 1, count: 10 }) do |event|
|
|
16
|
+
subscription.subscriber.call(event)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
11
19
|
end
|
|
20
|
+
threads.each(&:join) if wait
|
|
12
21
|
end
|
|
13
22
|
|
|
14
23
|
private
|
|
15
24
|
|
|
16
25
|
attr_reader :connection
|
|
26
|
+
attr_accessor :threads
|
|
17
27
|
|
|
18
28
|
def initialize(connection:)
|
|
19
29
|
@connection = connection
|
|
30
|
+
@threads = []
|
|
20
31
|
end
|
|
21
32
|
end
|
|
22
33
|
end
|
|
@@ -4,81 +4,42 @@ require 'dry-struct'
|
|
|
4
4
|
|
|
5
5
|
module EventStoreClient
|
|
6
6
|
class Client
|
|
7
|
+
include Configuration
|
|
8
|
+
|
|
7
9
|
NoCallMethodOnSubscriber = Class.new(StandardError)
|
|
8
10
|
WrongExpectedEventVersion = Class.new(StandardError)
|
|
9
11
|
|
|
10
|
-
def publish(stream:, events:,
|
|
11
|
-
connection.append_to_stream(stream, events,
|
|
12
|
-
rescue
|
|
12
|
+
def publish(stream:, events:, options: {})
|
|
13
|
+
connection.append_to_stream(stream, events, options: options)
|
|
14
|
+
rescue HTTP::Client::WrongExpectedEventVersion => e
|
|
13
15
|
raise WrongExpectedEventVersion.new(e.message)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
def read(stream,
|
|
17
|
-
if all
|
|
18
|
-
connection.read_all_from_stream(
|
|
19
|
-
stream, start: start, direction: direction, resolve_links: resolve_links
|
|
20
|
-
)
|
|
18
|
+
def read(stream, options: {})
|
|
19
|
+
if options[:all]
|
|
20
|
+
connection.read_all_from_stream(stream, options: options)
|
|
21
21
|
else
|
|
22
|
-
connection.read(
|
|
23
|
-
stream, start: start, direction: direction, resolve_links: resolve_links
|
|
24
|
-
)
|
|
22
|
+
connection.read(stream, options: options)
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
def subscribe(subscriber, to: []
|
|
26
|
+
def subscribe(subscriber, to: [])
|
|
29
27
|
raise NoCallMethodOnSubscriber unless subscriber.respond_to?(:call)
|
|
30
28
|
@subscriptions.create(subscriber, to)
|
|
31
|
-
poll if polling
|
|
32
29
|
end
|
|
33
30
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
@polling_started = true
|
|
37
|
-
thread1 = Thread.new do
|
|
38
|
-
loop do
|
|
39
|
-
create_pid_file
|
|
40
|
-
Thread.handle_interrupt(Interrupt => :never) do
|
|
41
|
-
begin # rubocop:disable Style/RedundantBegin
|
|
42
|
-
Thread.handle_interrupt(Interrupt => :immediate) do
|
|
43
|
-
broker.call(subscriptions)
|
|
44
|
-
end
|
|
45
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
46
|
-
# When the thread had been interrupted or broker.call returned an error
|
|
47
|
-
sleep(interval) # wait for events to be processed
|
|
48
|
-
delete_pid_file
|
|
49
|
-
error_handler&.call(e)
|
|
50
|
-
ensure
|
|
51
|
-
# this code is run always
|
|
52
|
-
Thread.stop
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
thread2 = Thread.new do
|
|
58
|
-
loop do
|
|
59
|
-
sleep 1
|
|
60
|
-
break unless thread1.alive?
|
|
61
|
-
thread1.run
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
@threads = [thread1, thread2]
|
|
65
|
-
nil
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def stop_polling
|
|
69
|
-
return if @threads.none?
|
|
70
|
-
@threads.each(&:kill)
|
|
71
|
-
@polling_started = false
|
|
72
|
-
nil
|
|
31
|
+
def listen(wait: false)
|
|
32
|
+
broker.call(@subscriptions, wait: wait)
|
|
73
33
|
end
|
|
74
34
|
|
|
75
35
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
76
|
-
def link_to(stream:, events:,
|
|
36
|
+
def link_to(stream:, events:, options: {})
|
|
77
37
|
raise ArgumentError if !stream || stream == ''
|
|
78
38
|
raise ArgumentError if events.nil? || (events.is_a?(Array) && events.empty?)
|
|
79
|
-
connection.link_to(stream, events,
|
|
80
|
-
|
|
81
|
-
|
|
39
|
+
res = connection.link_to(stream, events, options: options)
|
|
40
|
+
raise WrongExpectedEventVersion.new(e.message) if res.failure?
|
|
41
|
+
|
|
42
|
+
res.success?
|
|
82
43
|
end
|
|
83
44
|
# rubocop:enable Metrics/CyclomaticComplexity
|
|
84
45
|
|
|
@@ -88,10 +49,6 @@ module EventStoreClient
|
|
|
88
49
|
|
|
89
50
|
attr_reader :subscriptions, :broker, :error_handler
|
|
90
51
|
|
|
91
|
-
def config
|
|
92
|
-
EventStoreClient.config
|
|
93
|
-
end
|
|
94
|
-
|
|
95
52
|
def initialize
|
|
96
53
|
@threads = []
|
|
97
54
|
@connection ||= EventStoreClient.adapter
|
|
@@ -100,14 +57,5 @@ module EventStoreClient
|
|
|
100
57
|
@broker ||= Broker.new(connection: connection)
|
|
101
58
|
@subscriptions ||= Subscriptions.new(connection: connection, service: config.service_name)
|
|
102
59
|
end
|
|
103
|
-
|
|
104
|
-
def create_pid_file
|
|
105
|
-
Dir.mkdir('tmp') unless File.exist?('tmp')
|
|
106
|
-
File.open(config.pid_path, 'w') { |file| file.write(Process.pid) }
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def delete_pid_file
|
|
110
|
-
File.delete(config.pid_path) if File.exist?(config.pid_path)
|
|
111
|
-
end
|
|
112
60
|
end
|
|
113
61
|
end
|
|
@@ -5,9 +5,10 @@ require 'dry-configurable'
|
|
|
5
5
|
module EventStoreClient
|
|
6
6
|
extend Dry::Configurable
|
|
7
7
|
|
|
8
|
-
# Supported adapters: %i[api in_memory]
|
|
8
|
+
# Supported adapters: %i[api in_memory grpc]
|
|
9
9
|
#
|
|
10
|
-
setting :adapter, :
|
|
10
|
+
setting :adapter, :grpc
|
|
11
|
+
setting :verify_ssl, true
|
|
11
12
|
|
|
12
13
|
setting :error_handler
|
|
13
14
|
setting :eventstore_url, 'http://localhost:2113' do |value|
|
|
@@ -31,18 +32,31 @@ module EventStoreClient
|
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def self.adapter
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
@adapter =
|
|
36
|
+
case config.adapter
|
|
37
|
+
when :http
|
|
38
|
+
require 'event_store_client/adapters/http'
|
|
39
|
+
HTTP::Client.new
|
|
40
|
+
when :grpc
|
|
41
|
+
require 'event_store_client/adapters/grpc'
|
|
42
|
+
GRPC::Client.new
|
|
43
|
+
else
|
|
44
|
+
require 'event_store_client/adapters/in_memory'
|
|
45
|
+
InMemory.new(
|
|
46
|
+
mapper: config.mapper, per_page: config.per_page
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Configuration module to be included in classes required configured variables
|
|
52
|
+
# Usage: include EventStore::Configuration
|
|
53
|
+
# config.eventstore_url
|
|
54
|
+
#
|
|
55
|
+
module Configuration
|
|
56
|
+
# An instance of the EventStoreClient's configuration
|
|
57
|
+
#
|
|
58
|
+
def config
|
|
59
|
+
EventStoreClient.config
|
|
46
60
|
end
|
|
47
61
|
end
|
|
48
62
|
end
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'event_store_client/configuration'
|
|
4
|
+
|
|
3
5
|
module EventStoreClient
|
|
4
6
|
class DataDecryptor
|
|
7
|
+
include Configuration
|
|
8
|
+
|
|
5
9
|
KeyNotFoundError = Class.new(StandardError)
|
|
6
10
|
|
|
7
11
|
def call
|
|
@@ -26,12 +30,13 @@ module EventStoreClient
|
|
|
26
30
|
@encryption_metadata = schema&.transform_keys(&:to_s) || {}
|
|
27
31
|
end
|
|
28
32
|
|
|
29
|
-
def decrypt_attributes(key:, data:, attributes:)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
decrypted
|
|
33
|
+
def decrypt_attributes(key:, data:, attributes: {}) # rubocop:disable Lint/UnusedMethodArgument
|
|
34
|
+
res = key_repository.decrypt(key: key, message: data['es_encrypted'])
|
|
35
|
+
return data if res.failure?
|
|
36
|
+
|
|
37
|
+
decrypted_text = res.value!
|
|
38
|
+
decrypted = JSON.parse(decrypted_text.attributes[:message]).transform_keys(&:to_s)
|
|
39
|
+
decrypted.each { |k, value| data[k] = value if data.key?(k) }
|
|
35
40
|
data.delete('es_encrypted')
|
|
36
41
|
data
|
|
37
42
|
end
|
|
@@ -45,9 +50,9 @@ module EventStoreClient
|
|
|
45
50
|
def find_key(identifier)
|
|
46
51
|
key =
|
|
47
52
|
begin
|
|
48
|
-
key_repository.find(identifier)
|
|
53
|
+
key_repository.find(identifier).value!
|
|
49
54
|
rescue StandardError => e
|
|
50
|
-
|
|
55
|
+
config.error_handler&.call(e)
|
|
51
56
|
end
|
|
52
57
|
raise KeyNotFoundError unless key
|
|
53
58
|
|
|
@@ -6,8 +6,11 @@ module EventStoreClient
|
|
|
6
6
|
return encrypted_data if encryption_metadata.empty?
|
|
7
7
|
|
|
8
8
|
key_id = encryption_metadata[:key]
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
res = key_repository.find(key_id)
|
|
10
|
+
res = res.failure? ? key_repository.create(key_id) : res
|
|
11
|
+
key = res.value!
|
|
12
|
+
|
|
13
|
+
encryption_metadata[:iv] = key.attributes[:iv]
|
|
11
14
|
encrypt_attributes(
|
|
12
15
|
key: key,
|
|
13
16
|
data: encrypted_data,
|
|
@@ -29,11 +32,9 @@ module EventStoreClient
|
|
|
29
32
|
|
|
30
33
|
def encrypt_attributes(key:, data:, attributes:)
|
|
31
34
|
text = JSON.generate(data.select { |hash_key, _value| attributes.include?(hash_key.to_s) })
|
|
32
|
-
encrypted = key_repository.encrypt(
|
|
33
|
-
key_id: key.id, text: text, cipher: key.cipher, iv: key.iv
|
|
34
|
-
)
|
|
35
|
+
encrypted = key_repository.encrypt(key: key, message: text).value!
|
|
35
36
|
attributes.each { |att| data[att.to_s] = 'es_encrypted' if data.key?(att.to_s) }
|
|
36
|
-
data['es_encrypted'] = encrypted
|
|
37
|
+
data['es_encrypted'] = encrypted.attributes[:message]
|
|
37
38
|
data
|
|
38
39
|
end
|
|
39
40
|
|
|
@@ -22,7 +22,10 @@ module EventStoreClient
|
|
|
22
22
|
raise InvalidDataError.new(message: validation.errors.to_h) if validation.errors.any?
|
|
23
23
|
|
|
24
24
|
@data = args.fetch(:data) { {} }
|
|
25
|
-
@metadata = args.fetch(:metadata) { {} }
|
|
25
|
+
@metadata = args.fetch(:metadata) { {} }.merge(
|
|
26
|
+
'type' => self.class.name,
|
|
27
|
+
'content-type' => 'application/vnd.eventstore.events+json'
|
|
28
|
+
)
|
|
26
29
|
@type = args[:type] || self.class.name
|
|
27
30
|
@title = args[:title]
|
|
28
31
|
@id = args[:id]
|
|
@@ -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::
|
|
13
|
-
attribute :metadata, Types::
|
|
12
|
+
attribute :data, Types::Strict::String.default('{}')
|
|
13
|
+
attribute :metadata, Types::Strict::String.default('{}')
|
|
14
14
|
|
|
15
15
|
private
|
|
16
16
|
|
|
@@ -4,12 +4,13 @@ module EventStoreClient
|
|
|
4
4
|
class Subscriptions
|
|
5
5
|
def create(subscriber, event_types)
|
|
6
6
|
subscription = Subscription.new(subscriber, event_types: event_types, service: service)
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
unless @subscriptions.detect { |sub| sub.name == subscription.name }
|
|
9
|
-
|
|
9
|
+
connection.subscribe_to_stream(subscription)
|
|
10
|
+
subscriptions << subscription
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
subscription
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def each
|
|
@@ -18,18 +19,8 @@ module EventStoreClient
|
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
def get_updates(subscription)
|
|
22
|
-
connection.consume_feed(subscription.stream, subscription.name)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
22
|
private
|
|
26
23
|
|
|
27
|
-
def create_subscription(subscription)
|
|
28
|
-
# store position somewhere.
|
|
29
|
-
connection.join_streams(subscription.name, subscription.observed_streams)
|
|
30
|
-
connection.subscribe_to_stream(subscription.stream, subscription.name)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
24
|
attr_reader :connection, :subscriptions, :service
|
|
34
25
|
|
|
35
26
|
def initialize(connection:, service: 'default')
|
|
@@ -4,7 +4,9 @@ require 'dry-types'
|
|
|
4
4
|
|
|
5
5
|
module EventStoreClient
|
|
6
6
|
module Types
|
|
7
|
-
UUID_REGEXP =
|
|
7
|
+
UUID_REGEXP =
|
|
8
|
+
/\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\z/i.
|
|
9
|
+
freeze
|
|
8
10
|
|
|
9
11
|
include Dry.Types()
|
|
10
12
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EventStoreClient
|
|
4
|
+
class ReadDirection
|
|
5
|
+
Invalid = Class.new(StandardError)
|
|
6
|
+
|
|
7
|
+
def to_sym
|
|
8
|
+
value
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
value.to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
attr_reader :value
|
|
18
|
+
|
|
19
|
+
def initialize(str)
|
|
20
|
+
schema = Schema.new(direction: str)
|
|
21
|
+
|
|
22
|
+
unless %w[forwards backwards].include?(schema.direction)
|
|
23
|
+
raise Invalid.new('Allowed values: "forwards", "backwards"')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
@value = schema.direction.capitalize.to_sym
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Schema < Dry::Struct
|
|
31
|
+
schema schema.strict
|
|
32
|
+
|
|
33
|
+
# resolve default types on nil
|
|
34
|
+
transform_types do |type|
|
|
35
|
+
type.constructor do |value|
|
|
36
|
+
value.is_a?(String) ? value.downcase : value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attribute :direction, Dry::Types['string']
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
metadata
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: event_store_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.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:
|
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: dry-configurable
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.11'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dry-monads
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1'
|
|
13
41
|
- !ruby/object:Gem::Dependency
|
|
14
42
|
name: dry-schema
|
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,33 +81,33 @@ dependencies:
|
|
|
53
81
|
- !ruby/object:Gem::Version
|
|
54
82
|
version: '1.0'
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
84
|
+
name: grpc
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
58
86
|
requirements:
|
|
59
|
-
- - "
|
|
87
|
+
- - "~>"
|
|
60
88
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0
|
|
89
|
+
version: '1.0'
|
|
62
90
|
type: :runtime
|
|
63
91
|
prerelease: false
|
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
93
|
requirements:
|
|
66
|
-
- - "
|
|
94
|
+
- - "~>"
|
|
67
95
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0
|
|
96
|
+
version: '1.0'
|
|
69
97
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
98
|
+
name: rss
|
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
|
72
100
|
requirements:
|
|
73
101
|
- - ">="
|
|
74
102
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
103
|
+
version: 0.2.8
|
|
76
104
|
type: :runtime
|
|
77
105
|
prerelease: false
|
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
107
|
requirements:
|
|
80
108
|
- - ">="
|
|
81
109
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
110
|
+
version: 0.2.8
|
|
83
111
|
- !ruby/object:Gem::Dependency
|
|
84
112
|
name: rspec
|
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -119,6 +147,64 @@ files:
|
|
|
119
147
|
- README.md
|
|
120
148
|
- Rakefile
|
|
121
149
|
- lib/event_store_client.rb
|
|
150
|
+
- lib/event_store_client/adapters/grpc.rb
|
|
151
|
+
- lib/event_store_client/adapters/grpc/Protos/cluster.proto
|
|
152
|
+
- lib/event_store_client/adapters/grpc/Protos/gossip.proto
|
|
153
|
+
- lib/event_store_client/adapters/grpc/Protos/operations.proto
|
|
154
|
+
- lib/event_store_client/adapters/grpc/Protos/persistent.proto
|
|
155
|
+
- lib/event_store_client/adapters/grpc/Protos/projections.proto
|
|
156
|
+
- lib/event_store_client/adapters/grpc/Protos/shared.proto
|
|
157
|
+
- lib/event_store_client/adapters/grpc/Protos/streams.proto
|
|
158
|
+
- lib/event_store_client/adapters/grpc/Protos/users.proto
|
|
159
|
+
- lib/event_store_client/adapters/grpc/client.rb
|
|
160
|
+
- lib/event_store_client/adapters/grpc/command_registrar.rb
|
|
161
|
+
- lib/event_store_client/adapters/grpc/commands/command.rb
|
|
162
|
+
- lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/create.rb
|
|
163
|
+
- lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/delete.rb
|
|
164
|
+
- lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/read.rb
|
|
165
|
+
- lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/settings_schema.rb
|
|
166
|
+
- lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/update.rb
|
|
167
|
+
- lib/event_store_client/adapters/grpc/commands/projections/create.rb
|
|
168
|
+
- lib/event_store_client/adapters/grpc/commands/projections/delete.rb
|
|
169
|
+
- lib/event_store_client/adapters/grpc/commands/projections/update.rb
|
|
170
|
+
- lib/event_store_client/adapters/grpc/commands/streams/append.rb
|
|
171
|
+
- lib/event_store_client/adapters/grpc/commands/streams/delete.rb
|
|
172
|
+
- lib/event_store_client/adapters/grpc/commands/streams/link_to.rb
|
|
173
|
+
- lib/event_store_client/adapters/grpc/commands/streams/read.rb
|
|
174
|
+
- lib/event_store_client/adapters/grpc/commands/streams/read_all.rb
|
|
175
|
+
- lib/event_store_client/adapters/grpc/commands/streams/tombstone.rb
|
|
176
|
+
- lib/event_store_client/adapters/grpc/connection.rb
|
|
177
|
+
- lib/event_store_client/adapters/grpc/generated/cluster_pb.rb
|
|
178
|
+
- lib/event_store_client/adapters/grpc/generated/cluster_services_pb.rb
|
|
179
|
+
- lib/event_store_client/adapters/grpc/generated/gossip_pb.rb
|
|
180
|
+
- lib/event_store_client/adapters/grpc/generated/gossip_services_pb.rb
|
|
181
|
+
- lib/event_store_client/adapters/grpc/generated/operations_pb.rb
|
|
182
|
+
- lib/event_store_client/adapters/grpc/generated/operations_services_pb.rb
|
|
183
|
+
- lib/event_store_client/adapters/grpc/generated/persistent_pb.rb
|
|
184
|
+
- lib/event_store_client/adapters/grpc/generated/persistent_services_pb.rb
|
|
185
|
+
- lib/event_store_client/adapters/grpc/generated/projections_pb.rb
|
|
186
|
+
- lib/event_store_client/adapters/grpc/generated/projections_services_pb.rb
|
|
187
|
+
- lib/event_store_client/adapters/grpc/generated/shared_pb.rb
|
|
188
|
+
- lib/event_store_client/adapters/grpc/generated/streams_pb.rb
|
|
189
|
+
- lib/event_store_client/adapters/grpc/generated/streams_services_pb.rb
|
|
190
|
+
- lib/event_store_client/adapters/grpc/generated/users_pb.rb
|
|
191
|
+
- lib/event_store_client/adapters/grpc/generated/users_services_pb.rb
|
|
192
|
+
- lib/event_store_client/adapters/http.rb
|
|
193
|
+
- lib/event_store_client/adapters/http/README.md
|
|
194
|
+
- lib/event_store_client/adapters/http/client.rb
|
|
195
|
+
- lib/event_store_client/adapters/http/commands/command.rb
|
|
196
|
+
- lib/event_store_client/adapters/http/commands/persistent_subscriptions/ack.rb
|
|
197
|
+
- lib/event_store_client/adapters/http/commands/persistent_subscriptions/create.rb
|
|
198
|
+
- lib/event_store_client/adapters/http/commands/persistent_subscriptions/read.rb
|
|
199
|
+
- lib/event_store_client/adapters/http/commands/projections/create.rb
|
|
200
|
+
- lib/event_store_client/adapters/http/commands/streams/append.rb
|
|
201
|
+
- lib/event_store_client/adapters/http/commands/streams/delete.rb
|
|
202
|
+
- lib/event_store_client/adapters/http/commands/streams/link_to.rb
|
|
203
|
+
- lib/event_store_client/adapters/http/commands/streams/read.rb
|
|
204
|
+
- lib/event_store_client/adapters/http/commands/streams/tombstone.rb
|
|
205
|
+
- lib/event_store_client/adapters/http/connection.rb
|
|
206
|
+
- lib/event_store_client/adapters/http/request_method.rb
|
|
207
|
+
- lib/event_store_client/adapters/in_memory.rb
|
|
122
208
|
- lib/event_store_client/broker.rb
|
|
123
209
|
- lib/event_store_client/client.rb
|
|
124
210
|
- lib/event_store_client/configuration.rb
|
|
@@ -131,14 +217,10 @@ files:
|
|
|
131
217
|
- lib/event_store_client/mapper/default.rb
|
|
132
218
|
- lib/event_store_client/mapper/encrypted.rb
|
|
133
219
|
- lib/event_store_client/serializer/json.rb
|
|
134
|
-
- lib/event_store_client/store_adapter.rb
|
|
135
|
-
- lib/event_store_client/store_adapter/api/client.rb
|
|
136
|
-
- lib/event_store_client/store_adapter/api/connection.rb
|
|
137
|
-
- lib/event_store_client/store_adapter/api/request_method.rb
|
|
138
|
-
- lib/event_store_client/store_adapter/in_memory.rb
|
|
139
220
|
- lib/event_store_client/subscription.rb
|
|
140
221
|
- lib/event_store_client/subscriptions.rb
|
|
141
222
|
- lib/event_store_client/types.rb
|
|
223
|
+
- lib/event_store_client/value_objects/read_direction.rb
|
|
142
224
|
- lib/event_store_client/version.rb
|
|
143
225
|
homepage: https://github.com/yousty/event_store_client
|
|
144
226
|
licenses:
|