waterdrop 2.3.1 → 2.3.2

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: b73f2d492f65c1f7d410579f7bba30298eb4e3c2d7379b789e2cb10bda820eae
4
- data.tar.gz: 3ba7625727180dbeda0e0c29a6b36d83bae5d8b24103dd59995a7d96ca804062
3
+ metadata.gz: 154b5f8a103fcfaa47c5d410583d1aa2c0b689b52cd284614b06e7f7a9460179
4
+ data.tar.gz: c01ae313dbcf2830267438d3dd19f269a0a7bf29cad824af95f4313f6f04368e
5
5
  SHA512:
6
- metadata.gz: b073fdee0c430f1036d4c3219ba236f02ec33fe5350130d4fd448338f34f8ae3c63b424b093c78665c2f78ec9bfbc1b213a70dc536bd29110dae8530c208ceed
7
- data.tar.gz: 01ca4ea0a71137bbe3051e896319b9cdb81d6d6144945c0c85c95ce4644e66b3cbac5ad2187a1eb3073bc0a76783534872e713644b1fe90139a8b3bf6f01055f
6
+ metadata.gz: 33e5ab153d45e265dd6cdb2b3ab9bb63bda7c8c4399097f1c5c130d4c493de635ee7fad957c83b97d6e5fdd6c4c049a0419ca5e0e063f8163478182cde6b92ed
7
+ data.tar.gz: 3858e9ac8d2f860f888a5445ec8c59d98d35dce199816058da850bfaaf80308ccd40cff2eb5e872eb3ba111259c4c4d07d0a0219e0a641da0ad0c456d184030a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # WaterDrop changelog
2
2
 
3
+ ## 2.3.2 (2022-07-17)
4
+ - Replace `dry-configurable` with home-brew config and drop direct dependency on `dry-configurable`.
5
+
3
6
  ## 2.3.1 (2022-06-17)
4
7
  - Update rdkafka patches to align with `0.12.0` and `0.11.1` support.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterdrop (2.3.1)
4
+ waterdrop (2.3.2)
5
5
  concurrent-ruby (>= 1.1)
6
- dry-configurable (~> 0.13)
7
6
  dry-monitor (~> 0.5)
8
7
  dry-validation (~> 1.7)
9
8
  rdkafka (>= 0.10)
@@ -24,24 +23,24 @@ GEM
24
23
  dry-configurable (0.15.0)
25
24
  concurrent-ruby (~> 1.0)
26
25
  dry-core (~> 0.6)
27
- dry-container (0.9.0)
26
+ dry-container (0.10.0)
28
27
  concurrent-ruby (~> 1.0)
29
- dry-configurable (~> 0.13, >= 0.13.0)
30
- dry-core (0.7.1)
28
+ dry-core (0.8.0)
31
29
  concurrent-ruby (~> 1.0)
32
30
  dry-events (0.3.0)
33
31
  concurrent-ruby (~> 1.0)
34
32
  dry-core (~> 0.5, >= 0.5)
35
- dry-inflector (0.2.1)
33
+ dry-inflector (0.3.0)
36
34
  dry-initializer (3.1.1)
37
35
  dry-logic (1.2.0)
38
36
  concurrent-ruby (~> 1.0)
39
37
  dry-core (~> 0.5, >= 0.5)
40
- dry-monitor (0.5.0)
38
+ dry-monitor (0.6.1)
41
39
  dry-configurable (~> 0.13, >= 0.13.0)
42
40
  dry-core (~> 0.5, >= 0.5)
43
41
  dry-events (~> 0.2)
44
- dry-schema (1.9.2)
42
+ zeitwerk (~> 2.5)
43
+ dry-schema (1.9.3)
45
44
  concurrent-ruby (~> 1.0)
46
45
  dry-configurable (~> 0.13, >= 0.13.0)
47
46
  dry-core (~> 0.5, >= 0.5)
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # WaterDrop
2
2
 
3
- **Note**: Documentation presented here refers to WaterDrop `2.0.0`.
3
+ **Note**: Documentation presented here refers to WaterDrop `2.x`.
4
4
 
5
- WaterDrop `2.0` does **not** work with Karafka `1.*` and aims to either work as a standalone producer outside of Karafka `1.*` ecosystem or as a part of soon to be released Karafka `2.0.*`.
5
+ WaterDrop `2.x` does **not** work with Karafka `1.*` and aims to either work as a standalone producer outside of Karafka `1.*` ecosystem or as a part of soon to be released Karafka `2.0.*`.
6
6
 
7
7
  Please refer to [this](https://github.com/karafka/waterdrop/tree/1.4) branch and its documentation for details about WaterDrop `1.*` usage.
8
8
 
@@ -5,7 +5,7 @@
5
5
  module WaterDrop
6
6
  # Configuration object for setting up all options required by WaterDrop
7
7
  class Config
8
- include Dry::Configurable
8
+ include Configurable
9
9
 
10
10
  # Defaults for kafka settings, that will be overwritten only if not present already
11
11
  KAFKA_DEFAULTS = {
@@ -68,6 +68,8 @@ module WaterDrop
68
68
 
69
69
  ::Rdkafka::Config.logger = config.logger
70
70
  end
71
+
72
+ self
71
73
  end
72
74
 
73
75
  private
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaterDrop
4
+ module Configurable
5
+ # Single end config value representation
6
+ Leaf = Struct.new(:name, :default, :constructor)
7
+ end
8
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaterDrop
4
+ module Configurable
5
+ # Single non-leaf node
6
+ # This is a core component for the configurable settings
7
+ #
8
+ # The idea here is simple: we collect settings (leafs) and children (nodes) information and we
9
+ # only compile/initialize the values prior to user running the `#configure` API. This API needs
10
+ # to run prior to using the result stuff even if there is nothing to configure
11
+ class Node
12
+ attr_reader :name, :nestings
13
+
14
+ # We need to be able to redefine children for deep copy
15
+ attr_accessor :children
16
+
17
+ # @param name [Symbol] node name
18
+ # @param nestings [Proc] block for nested settings
19
+ def initialize(name, nestings = ->(_) {})
20
+ @name = name
21
+ @children = []
22
+ @nestings = nestings
23
+ instance_eval(&nestings)
24
+ end
25
+
26
+ # Allows for a single leaf or nested node definition
27
+ #
28
+ # @param name [Symbol] setting or nested node name
29
+ # @param default [Object] default value
30
+ # @param constructor [#call, nil] callable or nil
31
+ # @param block [Proc] block for nested settings
32
+ def setting(name, default: nil, constructor: nil, &block)
33
+ @children << if block
34
+ Node.new(name, block)
35
+ else
36
+ Leaf.new(name, default, constructor)
37
+ end
38
+ end
39
+
40
+ # Allows for the configuration and setup of the settings
41
+ #
42
+ # Compile settings, allow for overrides via yielding
43
+ # @return [Node] returns self after configuration
44
+ def configure
45
+ compile
46
+ yield(self) if block_given?
47
+ self
48
+ end
49
+
50
+ # @return [Hash] frozen config hash representation
51
+ def to_h
52
+ config = {}
53
+
54
+ @children.each do |value|
55
+ config[value.name] = if value.is_a?(Leaf)
56
+ public_send(value.name)
57
+ else
58
+ value.to_h
59
+ end
60
+ end
61
+
62
+ config.freeze
63
+ end
64
+
65
+ # Deep copies all the children nodes to allow us for templates building on a class level and
66
+ # non-side-effect usage on an instance/inherited.
67
+ # @return [Node] duplicated node
68
+ def deep_dup
69
+ dupped = Node.new(name, nestings)
70
+
71
+ dupped.children += children.map do |value|
72
+ value.is_a?(Leaf) ? value.dup : value.deep_dup
73
+ end
74
+
75
+ dupped
76
+ end
77
+
78
+ # Converts the settings definitions into end children
79
+ # @note It runs once, after things are compiled, they will not be recompiled again
80
+ def compile
81
+ @children.each do |value|
82
+ # Do not redefine something that was already set during compilation
83
+ # This will allow us to reconfigure things and skip override with defaults
84
+ next if respond_to?(value.name)
85
+
86
+ singleton_class.attr_accessor value.name
87
+
88
+ initialized = if value.is_a?(Leaf)
89
+ value.constructor ? value.constructor.call(value.default) : value.default
90
+ else
91
+ value.compile
92
+ value
93
+ end
94
+
95
+ public_send("#{value.name}=", initialized)
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WaterDrop
4
+ # A simple dry-configuration API compatible module for defining settings with defaults and a
5
+ # constructor.
6
+ module Configurable
7
+ # A simple settings layer that works similar to dry-configurable
8
+ # It allows us to define settings on a class and per instance level with templating on a class
9
+ # level. It handles inheritance and allows for nested settings.
10
+ #
11
+ # @note The core settings template needs to be defined on a class level
12
+ class << self
13
+ # Sets up all the class methods and inits the core root node.
14
+ # Useful when only per class settings are needed as does not include instance methods
15
+ # @param base [Class] class that we extend
16
+ def extended(base)
17
+ base.extend ClassMethods
18
+ end
19
+
20
+ # Sets up all the class and instance methods and inits the core root node
21
+ #
22
+ # @param base [Class] class to which we want to add configuration
23
+ #
24
+ # Needs to be used when per instance configuration is needed
25
+ def included(base)
26
+ base.include InstanceMethods
27
+ base.extend self
28
+ end
29
+ end
30
+
31
+ # Instance related methods
32
+ module InstanceMethods
33
+ # @return [Node] config root node
34
+ def config
35
+ @config ||= self.class.config.deep_dup
36
+ end
37
+
38
+ # Allows for a per instance configuration (if needed)
39
+ # @param block [Proc] block for configuration
40
+ def configure(&block)
41
+ config.configure(&block)
42
+ end
43
+ end
44
+
45
+ # Class related methods
46
+ module ClassMethods
47
+ # @return [Node] root node for the settings
48
+ def config
49
+ return @config if @config
50
+
51
+ # This will handle inheritance
52
+ @config = if superclass.respond_to?(:config)
53
+ superclass.config.deep_dup
54
+ else
55
+ Node.new(:root)
56
+ end
57
+ end
58
+
59
+ # Allows for a per class configuration (if needed)
60
+ # @param block [Proc] block for configuration
61
+ def configure(&block)
62
+ config.configure(&block)
63
+ end
64
+
65
+ # Pipes the settings setup to the config root node
66
+ def setting(...)
67
+ config.setting(...)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -3,5 +3,5 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Current WaterDrop version
6
- VERSION = '2.3.1'
6
+ VERSION = '2.3.2'
7
7
  end
data/lib/waterdrop.rb CHANGED
@@ -4,7 +4,6 @@
4
4
  # delegate should be removed because we don't need it, we just add it because of ruby-kafka
5
5
  %w[
6
6
  concurrent/array
7
- dry-configurable
8
7
  dry/monitor/notifications
9
8
  dry-validation
10
9
  rdkafka
data/waterdrop.gemspec CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.license = 'MIT'
18
18
 
19
19
  spec.add_dependency 'concurrent-ruby', '>= 1.1'
20
- spec.add_dependency 'dry-configurable', '~> 0.13'
21
20
  spec.add_dependency 'dry-monitor', '~> 0.5'
22
21
  spec.add_dependency 'dry-validation', '~> 1.7'
23
22
  spec.add_dependency 'rdkafka', '>= 0.10'
data.tar.gz.sig CHANGED
Binary file
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: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -34,7 +34,7 @@ cert_chain:
34
34
  R2P11bWoCtr70BsccVrN8jEhzwXngMyI2gVt750Y+dbTu1KgRqZKp/ECe7ZzPzXj
35
35
  pIy9vHxTANKYVyI4qj8OrFdEM5BQNu8oQpL0iQ==
36
36
  -----END CERTIFICATE-----
37
- date: 2022-06-17 00:00:00.000000000 Z
37
+ date: 2022-07-17 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: concurrent-ruby
@@ -50,20 +50,6 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.1'
53
- - !ruby/object:Gem::Dependency
54
- name: dry-configurable
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '0.13'
60
- type: :runtime
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '0.13'
67
53
  - !ruby/object:Gem::Dependency
68
54
  name: dry-monitor
69
55
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +130,9 @@ files:
144
130
  - docker-compose.yml
145
131
  - lib/waterdrop.rb
146
132
  - lib/waterdrop/config.rb
133
+ - lib/waterdrop/configurable.rb
134
+ - lib/waterdrop/configurable/leaf.rb
135
+ - lib/waterdrop/configurable/node.rb
147
136
  - lib/waterdrop/contracts.rb
148
137
  - lib/waterdrop/contracts/base.rb
149
138
  - lib/waterdrop/contracts/config.rb
@@ -192,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
181
  - !ruby/object:Gem::Version
193
182
  version: '0'
194
183
  requirements: []
195
- rubygems_version: 3.2.20
184
+ rubygems_version: 3.3.7
196
185
  signing_key:
197
186
  specification_version: 4
198
187
  summary: Kafka messaging made easy!
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- Ӑ�v�ij( �.kzT�� MK�����u����QYH�\���ú�pt��:,;e�a��hU��B֬�j����k�>I��č+�����4�!;�C��[�j2�d����¢��h�����q�^��_�*D��O9���A�G��?+ҏF���Wq�@"i���E iM��� b�OnS�})w#�
1
+ -���mE�ΕQQiPq�ǶKP k�]N|�<�b^@�{�@�i�[��B��7މ_˘d�v;G�8%��HticDU+