event_store_client 2.1.5 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/configuration.md +46 -9
- data/lib/event_store_client/adapters/grpc/cluster/insecure_connection.rb +1 -1
- data/lib/event_store_client/adapters/grpc/cluster/secure_connection.rb +1 -1
- data/lib/event_store_client/adapters/grpc/connection.rb +0 -17
- data/lib/event_store_client/config.rb +54 -0
- data/lib/event_store_client/configuration.rb +1 -50
- data/lib/event_store_client/connection/url.rb +8 -0
- data/lib/event_store_client/version.rb +1 -1
- data/lib/event_store_client.rb +19 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f072cd6b9f3a8cb41ac746eed4cb472cf0581c042c117082076c9f29b391bbd5
|
4
|
+
data.tar.gz: 3fa6712c4be66e24b97bf364c22cbca1318a7681e1bc5ea765268ea19495545e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0d8489a114c666079639e76817a01f1986df193434cdf0efc22e5fea968e4670e96176a433464ac2f5669f3bfdae5ef94a7b2f19b87a5ef891aebef5c6f65e2
|
7
|
+
data.tar.gz: 4e9ae526f384e00b2f4d5739b4f825f5336d87a9193e02f01ee87f94282c385344750653d844074e431ae1d59bad93270a362caa8d92c1a2972544e037372620
|
data/docs/configuration.md
CHANGED
@@ -6,15 +6,52 @@ Currently only one setup is supported. For example, you can't configure a connec
|
|
6
6
|
|
7
7
|
Configuration options:
|
8
8
|
|
9
|
-
| name | value | default value
|
10
|
-
|
11
|
-
| eventstore_url | String | `'esdb://localhost:2113'`
|
12
|
-
| per_page | Integer | `20`
|
13
|
-
| mapper | `EventStoreClient::Mapper::Default.new` or `EventStoreClient::Mapper::Encrypted.new` | `EventStoreClient::Mapper::Default.new`
|
14
|
-
| default_event_class | `DeserializedEvent` or any class, inherited from it | `DeserializedEvent`
|
15
|
-
| logger | `Logger` | `nil`
|
16
|
-
| skip_deserialization | Boolean | `false`
|
17
|
-
| skip_decryption | Boolean | `false`
|
9
|
+
| name | value | default value | description |
|
10
|
+
|----------------------|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
11
|
+
| eventstore_url | String | `'esdb://localhost:2113'` | Connection string. See description of possible values below. |
|
12
|
+
| per_page | Integer | `20` | Number of events to return in one response. |
|
13
|
+
| mapper | `EventStoreClient::Mapper::Default.new` or `EventStoreClient::Mapper::Encrypted.new` | `EventStoreClient::Mapper::Default.new` | An object that is responsible for serialization / deserialization and encryption / decryption of events. |
|
14
|
+
| default_event_class | `DeserializedEvent` or any class, inherited from it | `DeserializedEvent` | This class will be used during the deserialization process when deserializer fails to resolve an event's class from response. |
|
15
|
+
| logger | `Logger` | `nil` | A logger that would log messages from `event_store_client` and `grpc` gems. |
|
16
|
+
| skip_deserialization | Boolean | `false` | Whether to skip event deserialization using the given `mapper` setting. If you set it to `true` decryption will be skipped as well. It is useful when you want to defer deserialization and handle it later by yourself. |
|
17
|
+
| skip_decryption | Boolean | `false` | Whether to skip decrypting encrypted event payloads. |
|
18
|
+
| channel_args | Hash | `{ 'grpc.min_reconnect_backoff_ms' => 100, 'grpc.max_reconnect_backoff_ms' => 100, 'grpc.initial_reconnect_backoff_ms' => 100 }` | GRPC-specific connection options. This hash will be passed into the `:channel_args` argument of a Stub class of your request. More GRPC options can be found [here](https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/grpc_types.h). |
|
19
|
+
|
20
|
+
## A note about channel_args option
|
21
|
+
|
22
|
+
When defining the custom value of this option - the default value will be reverse-merged into it. So, for example, if you would like to set `grpc.min_reconnect_backoff_ms` like so:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
EventStoreClient.configure do |config|
|
26
|
+
config.channel_args = { 'grpc.min_reconnect_backoff_ms' => 200 }
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
the resulting `channel_args` value will be
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
{
|
34
|
+
"grpc.min_reconnect_backoff_ms" => 200,
|
35
|
+
"grpc.max_reconnect_backoff_ms" => 100,
|
36
|
+
"grpc.initial_reconnect_backoff_ms" => 100
|
37
|
+
}
|
38
|
+
```
|
39
|
+
|
40
|
+
This behaviour is intentional. So, if you want to override them all - you should do it explicitly. Example:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
EventStoreClient.configure do |config|
|
44
|
+
config.channel_args = {
|
45
|
+
'grpc.min_reconnect_backoff_ms' => 500,
|
46
|
+
'grpc.max_reconnect_backoff_ms' => 500,
|
47
|
+
'grpc.initial_reconnect_backoff_ms' => 500
|
48
|
+
}
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
It could be useful when you have high ping to your EventStore DB server.
|
53
|
+
|
54
|
+
Besides, there is an option which you can't change - `grpc.enable_retries`. It always defaults to `0`. This is because `event_store_client` implements its own retry functional.
|
18
55
|
|
19
56
|
## Connection string
|
20
57
|
|
@@ -55,23 +55,6 @@ module EventStoreClient
|
|
55
55
|
def call(stub_class)
|
56
56
|
raise NotImplementedError
|
57
57
|
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
# Common channel arguments for all GRPC requests.
|
62
|
-
# Available channel arguments are described here
|
63
|
-
# https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/grpc_types.h
|
64
|
-
# @return [Hash]
|
65
|
-
def channel_args
|
66
|
-
{
|
67
|
-
# disable build-in GRPC retries functional
|
68
|
-
'grpc.enable_retries' => 0,
|
69
|
-
# These three options reduce delays between failed requests.
|
70
|
-
'grpc.min_reconnect_backoff_ms' => 100, # milliseconds
|
71
|
-
'grpc.max_reconnect_backoff_ms' => 100, # milliseconds
|
72
|
-
'grpc.initial_reconnect_backoff_ms' => 100 # milliseconds
|
73
|
-
}
|
74
|
-
end
|
75
58
|
end
|
76
59
|
end
|
77
60
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EventStoreClient
|
4
|
+
class Config
|
5
|
+
include Extensions::OptionsExtension
|
6
|
+
|
7
|
+
CHANNEL_ARGS_DEFAULTS = {
|
8
|
+
# These three options reduce delays between failed requests.
|
9
|
+
'grpc.min_reconnect_backoff_ms' => 100, # milliseconds
|
10
|
+
'grpc.max_reconnect_backoff_ms' => 100, # milliseconds
|
11
|
+
'grpc.initial_reconnect_backoff_ms' => 100 # milliseconds
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
option(:eventstore_url) { 'esdb://localhost:2113' }
|
15
|
+
option(:per_page) { 20 }
|
16
|
+
option(:mapper) { Mapper::Default.new }
|
17
|
+
option(:default_event_class) { DeserializedEvent }
|
18
|
+
option(:logger)
|
19
|
+
option(:skip_deserialization) { false }
|
20
|
+
option(:skip_decryption) { false }
|
21
|
+
# GRPC-specific connection options. This hash will be passed into the `:channel_args` argument
|
22
|
+
# of a Stub class of your request. More GRPC options can be found here
|
23
|
+
# https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/grpc_types.h
|
24
|
+
option(:channel_args) # Hash
|
25
|
+
|
26
|
+
def eventstore_url=(value)
|
27
|
+
@eventstore_url =
|
28
|
+
if value.is_a?(Connection::Url)
|
29
|
+
value
|
30
|
+
else
|
31
|
+
Connection::UrlParser.new.call(value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param logger [Logger, nil]
|
36
|
+
# @return [Logger, nil]
|
37
|
+
def logger=(logger)
|
38
|
+
::GRPC.define_singleton_method :logger do
|
39
|
+
@logger ||= logger.nil? ? ::GRPC::DefaultLogger::NoopLogger.new : logger
|
40
|
+
end
|
41
|
+
@logger = logger
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param val [Hash, nil]
|
45
|
+
# @return [Hash]
|
46
|
+
def channel_args=(val)
|
47
|
+
channel_args = CHANNEL_ARGS_DEFAULTS.merge(val&.transform_keys(&:to_s) || {})
|
48
|
+
# This options always defaults to `0`. This is because `event_store_client` implements its
|
49
|
+
# own retry functional.
|
50
|
+
channel_args['grpc.enable_retries'] = 0
|
51
|
+
@channel_args = channel_args
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,57 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module EventStoreClient
|
4
|
-
class Config
|
5
|
-
include Extensions::OptionsExtension
|
6
|
-
|
7
|
-
option(:eventstore_url) { 'esdb://localhost:2113' }
|
8
|
-
option(:per_page) { 20 }
|
9
|
-
option(:mapper) { Mapper::Default.new }
|
10
|
-
option(:default_event_class) { DeserializedEvent }
|
11
|
-
option(:logger)
|
12
|
-
option(:skip_deserialization) { false }
|
13
|
-
option(:skip_decryption) { false }
|
14
|
-
|
15
|
-
def eventstore_url=(value)
|
16
|
-
@eventstore_url =
|
17
|
-
if value.is_a?(Connection::Url)
|
18
|
-
value
|
19
|
-
else
|
20
|
-
Connection::UrlParser.new.call(value)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# @param logger [Logger, nil]
|
25
|
-
# @return [Logger, nil]
|
26
|
-
def logger=(logger)
|
27
|
-
::GRPC.define_singleton_method :logger do
|
28
|
-
@logger ||= logger.nil? ? ::GRPC::DefaultLogger::NoopLogger.new : logger
|
29
|
-
end
|
30
|
-
@logger = logger
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class << self
|
35
|
-
def configure
|
36
|
-
yield(config) if block_given?
|
37
|
-
end
|
38
|
-
|
39
|
-
def config
|
40
|
-
@config ||= Config.new
|
41
|
-
end
|
42
|
-
|
43
|
-
def client
|
44
|
-
GRPC::Client.new
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Configuration module to be included in classes required configured variables
|
49
|
-
# Usage: include EventStore::Configuration
|
50
|
-
# config.eventstore_url
|
51
|
-
#
|
52
4
|
module Configuration
|
53
|
-
#
|
54
|
-
#
|
5
|
+
# @return [EventStoreClient::Config]
|
55
6
|
def config
|
56
7
|
EventStoreClient.config
|
57
8
|
end
|
@@ -52,6 +52,14 @@ module EventStoreClient
|
|
52
52
|
option(:grpc_retry_attempts) { 3 }
|
53
53
|
# Delay between GRPC request retries
|
54
54
|
option(:grpc_retry_interval) { 100 } # milliseconds
|
55
|
+
|
56
|
+
# @param other [EventStoreClient::Connection::Url, Object]
|
57
|
+
# @return [Boolean]
|
58
|
+
def ==(other)
|
59
|
+
return false unless other.is_a?(Url)
|
60
|
+
|
61
|
+
options_hash == other.options_hash
|
62
|
+
end
|
55
63
|
end
|
56
64
|
end
|
57
65
|
end
|
data/lib/event_store_client.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module EventStoreClient
|
4
|
-
end
|
5
|
-
|
6
3
|
require 'json'
|
7
4
|
require 'set'
|
8
5
|
|
@@ -18,8 +15,27 @@ require 'event_store_client/connection/url'
|
|
18
15
|
require 'event_store_client/connection/url_parser'
|
19
16
|
require 'event_store_client/deserialized_event'
|
20
17
|
require 'event_store_client/serialized_event'
|
18
|
+
require 'event_store_client/config'
|
21
19
|
require 'event_store_client/configuration'
|
22
20
|
|
23
21
|
require 'event_store_client/mapper'
|
24
22
|
|
25
23
|
require 'event_store_client/adapters/grpc'
|
24
|
+
|
25
|
+
module EventStoreClient
|
26
|
+
class << self
|
27
|
+
def configure
|
28
|
+
yield(config) if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [EventStore::Config]
|
32
|
+
def config
|
33
|
+
@config ||= Config.new
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [EventStore::GRPC::Client]
|
37
|
+
def client
|
38
|
+
GRPC::Client.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_store_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Wilgosz
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/event_store_client/adapters/grpc/shared/options/stream_options.rb
|
215
215
|
- lib/event_store_client/adapters/grpc/shared/streams/process_response.rb
|
216
216
|
- lib/event_store_client/adapters/grpc/shared/streams/process_responses.rb
|
217
|
+
- lib/event_store_client/config.rb
|
217
218
|
- lib/event_store_client/configuration.rb
|
218
219
|
- lib/event_store_client/connection/url.rb
|
219
220
|
- lib/event_store_client/connection/url_parser.rb
|