waterdrop 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/water_drop.rb +2 -15
- data/lib/water_drop/config.rb +0 -11
- data/lib/water_drop/config_applier.rb +51 -0
- data/lib/water_drop/schemas/config.rb +3 -3
- data/lib/water_drop/version.rb +1 -1
- 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: a79785b00fcedfb6385e4a5afeba36ba905ab2e6168b8efd9ec9ea2185382723
|
4
|
+
data.tar.gz: 388da5d63dcfee4acc918e7dfa1b65d969b28950eb4094d5314e58c74aabd322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 648f5ff9824df4cbe8f597e9c4c635d31f2ae4bab6cda643657ebe759a96a83e168166192b023aebdc6a848d1dfc27e18b69b0ccc101e37eac621dfc316a7424
|
7
|
+
data.tar.gz: 1a32f771148dd11f7836468acc9e92d77b3997b6bb3866587684548be464b5450251455b239c19794d5701bdc911cbb016c7b68e69dfb411963d5ea8cf8c8aa6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/water_drop.rb
CHANGED
@@ -23,22 +23,8 @@ module WaterDrop
|
|
23
23
|
# @param [Block] block configuration block
|
24
24
|
def setup(&block)
|
25
25
|
Config.setup(&block)
|
26
|
-
|
27
26
|
DeliveryBoy.logger = self.logger = config.logger
|
28
|
-
|
29
|
-
# Recursive lambda for mapping config down to delivery boy
|
30
|
-
applier = lambda { |db_config, h|
|
31
|
-
h.each do |k, v|
|
32
|
-
applier.call(db_config, v) && next if v.is_a?(Hash)
|
33
|
-
next unless db_config.respond_to?(:"#{k}=")
|
34
|
-
db_config.public_send(:"#{k}=", v)
|
35
|
-
end
|
36
|
-
}
|
37
|
-
|
38
|
-
DeliveryBoy.config.tap do |config|
|
39
|
-
config.brokers = Config.config.kafka.seed_brokers
|
40
|
-
applier.call(config, Config.config.to_h)
|
41
|
-
end
|
27
|
+
ConfigApplier.call(DeliveryBoy.config, Config.config.to_h)
|
42
28
|
end
|
43
29
|
|
44
30
|
# @return [WaterDrop::Config] config instance
|
@@ -65,6 +51,7 @@ end
|
|
65
51
|
schemas/message_options
|
66
52
|
schemas/config
|
67
53
|
config
|
54
|
+
config_applier
|
68
55
|
errors
|
69
56
|
base_producer
|
70
57
|
sync_producer
|
data/lib/water_drop/config.rb
CHANGED
@@ -110,17 +110,6 @@ module WaterDrop
|
|
110
110
|
setting :sasl_scram_mechanism, nil
|
111
111
|
end
|
112
112
|
|
113
|
-
# option producer [Hash] - optional - producer configuration options
|
114
|
-
setting :producer do
|
115
|
-
# option compression_codec [Symbol] Sets producer compression codec
|
116
|
-
# More: https://github.com/zendesk/ruby-kafka#compression
|
117
|
-
# More: https://github.com/zendesk/ruby-kafka/blob/master/lib/kafka/compression.rb
|
118
|
-
setting :compression_codec, nil
|
119
|
-
# option compression_codec [Integer] Sets producer compression threshold
|
120
|
-
# More: https://github.com/zendesk/ruby-kafka#compression
|
121
|
-
setting :compression_threshold, 1
|
122
|
-
end
|
123
|
-
|
124
113
|
class << self
|
125
114
|
# Configurating method
|
126
115
|
# @yield Runs a block of code providing a config singleton instance to it
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WaterDrop
|
4
|
+
# Engine used to propagate config application to DeliveryBoy with corner case handling
|
5
|
+
module ConfigApplier
|
6
|
+
class << self
|
7
|
+
# @param delivery_boy_config [DeliveryBoy::Config] delivery boy config instance
|
8
|
+
# @param settings [Hash] hash with WaterDrop settings
|
9
|
+
def call(delivery_boy_config, settings)
|
10
|
+
# Recursive lambda for mapping config down to delivery boy
|
11
|
+
settings.each do |key, value|
|
12
|
+
call(delivery_boy_config, value) && next if value.is_a?(Hash)
|
13
|
+
|
14
|
+
# If this is a special case that needs manual setup instead of a direct reassignment
|
15
|
+
if respond_to?(key, true)
|
16
|
+
send(key, delivery_boy_config, value)
|
17
|
+
else
|
18
|
+
# If this setting is our internal one, we should not sync it with the delivery boy
|
19
|
+
next unless delivery_boy_config.respond_to?(:"#{key}=")
|
20
|
+
|
21
|
+
delivery_boy_config.public_send(:"#{key}=", value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# Extra setup for the compression codec as it behaves differently than other settings
|
29
|
+
# that are ported 1:1 from ruby-kafka
|
30
|
+
# For some crazy reason, delivery boy requires compression codec as a string, when
|
31
|
+
# ruby-kafka as a symbol. We follow ruby-kafka internal design, so we had to mimic
|
32
|
+
# that by assigning a stringified version that down the road will be symbolized again
|
33
|
+
# by delivery boy
|
34
|
+
# @param delivery_boy_config [DeliveryBoy::Config] delivery boy config instance
|
35
|
+
# @param codec_name [Symbol] codec name as a symbol
|
36
|
+
def compression_codec(delivery_boy_config, codec_name)
|
37
|
+
# If there is no compression codec, we don't apply anything
|
38
|
+
return unless codec_name
|
39
|
+
delivery_boy_config.compression_codec = codec_name.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
# We use the "seed_brokers" name and DeliveryBoy uses "brokers" so we pass the values
|
43
|
+
# manually
|
44
|
+
# @param delivery_boy_config [DeliveryBoy::Config] delivery boy config instance
|
45
|
+
# @param seed_brokers [Array<String>] kafka seed brokers
|
46
|
+
def seed_brokers(delivery_boy_config, seed_brokers)
|
47
|
+
delivery_boy_config.brokers = seed_brokers
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -37,10 +37,10 @@ module WaterDrop
|
|
37
37
|
|
38
38
|
required(:kafka).schema do
|
39
39
|
required(:seed_brokers).filled { each(:broker_schema?) }
|
40
|
-
required(:connect_timeout).filled
|
41
|
-
required(:socket_timeout).filled
|
40
|
+
required(:connect_timeout).filled(:int?, gt?: 0)
|
41
|
+
required(:socket_timeout).filled(:int?, gt?: 0)
|
42
42
|
required(:compression_threshold).filled(:int?, gteq?: 1)
|
43
|
-
optional(:compression_codec).maybe(included_in?: %
|
43
|
+
optional(:compression_codec).maybe(included_in?: %i[snappy gzip lz4])
|
44
44
|
|
45
45
|
required(:max_buffer_bytesize).filled(:int?, gt?: 0)
|
46
46
|
required(:max_buffer_size).filled(:int?, gt?: 0)
|
data/lib/water_drop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waterdrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/water_drop/async_producer.rb
|
103
103
|
- lib/water_drop/base_producer.rb
|
104
104
|
- lib/water_drop/config.rb
|
105
|
+
- lib/water_drop/config_applier.rb
|
105
106
|
- lib/water_drop/errors.rb
|
106
107
|
- lib/water_drop/instrumentation/listener.rb
|
107
108
|
- lib/water_drop/instrumentation/monitor.rb
|