waterdrop 2.2.0 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +21 -21
- data/README.md +3 -3
- data/lib/waterdrop/config.rb +3 -1
- data/lib/waterdrop/configurable/leaf.rb +8 -0
- data/lib/waterdrop/configurable/node.rb +100 -0
- data/lib/waterdrop/configurable.rb +71 -0
- data/lib/waterdrop/instrumentation/{stdout_listener.rb → logger_listener.rb} +2 -2
- data/lib/waterdrop/patches/rdkafka/producer.rb +9 -1
- data/lib/waterdrop/version.rb +1 -1
- data/lib/waterdrop.rb +0 -1
- data/waterdrop.gemspec +0 -1
- data.tar.gz.sig +0 -0
- metadata +7 -18
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154b5f8a103fcfaa47c5d410583d1aa2c0b689b52cd284614b06e7f7a9460179
|
4
|
+
data.tar.gz: c01ae313dbcf2830267438d3dd19f269a0a7bf29cad824af95f4313f6f04368e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e5ab153d45e265dd6cdb2b3ab9bb63bda7c8c4399097f1c5c130d4c493de635ee7fad957c83b97d6e5fdd6c4c049a0419ca5e0e063f8163478182cde6b92ed
|
7
|
+
data.tar.gz: 3858e9ac8d2f860f888a5445ec8c59d98d35dce199816058da850bfaaf80308ccd40cff2eb5e872eb3ba111259c4c4d07d0a0219e0a641da0ad0c456d184030a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
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
|
+
|
6
|
+
## 2.3.1 (2022-06-17)
|
7
|
+
- Update rdkafka patches to align with `0.12.0` and `0.11.1` support.
|
8
|
+
|
9
|
+
## 2.3.0 (2022-04-03)
|
10
|
+
- Rename StdoutListener to LoggerListener (#240)
|
11
|
+
|
3
12
|
## 2.2.0 (2022-02-18)
|
4
13
|
- Add Datadog listener for metrics + errors publishing
|
5
14
|
- Add Datadog example dashboard template
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waterdrop (2.2
|
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)
|
@@ -12,36 +11,36 @@ PATH
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
14
13
|
specs:
|
15
|
-
activesupport (7.0.
|
14
|
+
activesupport (7.0.3)
|
16
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
16
|
i18n (>= 1.6, < 2)
|
18
17
|
minitest (>= 5.1)
|
19
18
|
tzinfo (~> 2.0)
|
20
19
|
byebug (11.1.3)
|
21
|
-
concurrent-ruby (1.1.
|
20
|
+
concurrent-ruby (1.1.10)
|
22
21
|
diff-lcs (1.5.0)
|
23
22
|
docile (1.4.0)
|
24
|
-
dry-configurable (0.
|
23
|
+
dry-configurable (0.15.0)
|
25
24
|
concurrent-ruby (~> 1.0)
|
26
25
|
dry-core (~> 0.6)
|
27
|
-
dry-container (0.
|
26
|
+
dry-container (0.10.0)
|
28
27
|
concurrent-ruby (~> 1.0)
|
29
|
-
|
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.
|
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.
|
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
|
-
|
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)
|
@@ -54,21 +53,21 @@ GEM
|
|
54
53
|
dry-core (~> 0.5, >= 0.5)
|
55
54
|
dry-inflector (~> 0.1, >= 0.1.2)
|
56
55
|
dry-logic (~> 1.0, >= 1.0.2)
|
57
|
-
dry-validation (1.
|
56
|
+
dry-validation (1.8.1)
|
58
57
|
concurrent-ruby (~> 1.0)
|
59
58
|
dry-container (~> 0.7, >= 0.7.1)
|
60
59
|
dry-core (~> 0.5, >= 0.5)
|
61
60
|
dry-initializer (~> 3.0)
|
62
61
|
dry-schema (~> 1.8, >= 1.8.0)
|
63
|
-
factory_bot (6.2.
|
62
|
+
factory_bot (6.2.1)
|
64
63
|
activesupport (>= 5.0.0)
|
65
64
|
ffi (1.15.5)
|
66
|
-
i18n (1.
|
65
|
+
i18n (1.10.0)
|
67
66
|
concurrent-ruby (~> 1.0)
|
68
|
-
mini_portile2 (2.
|
69
|
-
minitest (5.
|
67
|
+
mini_portile2 (2.8.0)
|
68
|
+
minitest (5.16.0)
|
70
69
|
rake (13.0.6)
|
71
|
-
rdkafka (0.
|
70
|
+
rdkafka (0.12.0)
|
72
71
|
ffi (~> 1.15)
|
73
72
|
mini_portile2 (~> 2.6)
|
74
73
|
rake (> 12)
|
@@ -81,7 +80,7 @@ GEM
|
|
81
80
|
rspec-expectations (3.11.0)
|
82
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
82
|
rspec-support (~> 3.11.0)
|
84
|
-
rspec-mocks (3.11.
|
83
|
+
rspec-mocks (3.11.1)
|
85
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
86
85
|
rspec-support (~> 3.11.0)
|
87
86
|
rspec-support (3.11.0)
|
@@ -90,12 +89,13 @@ GEM
|
|
90
89
|
simplecov-html (~> 0.11)
|
91
90
|
simplecov_json_formatter (~> 0.1)
|
92
91
|
simplecov-html (0.12.3)
|
93
|
-
simplecov_json_formatter (0.1.
|
92
|
+
simplecov_json_formatter (0.1.4)
|
94
93
|
tzinfo (2.0.4)
|
95
94
|
concurrent-ruby (~> 1.0)
|
96
|
-
zeitwerk (2.
|
95
|
+
zeitwerk (2.6.0)
|
97
96
|
|
98
97
|
PLATFORMS
|
98
|
+
arm64-darwin-21
|
99
99
|
x86_64-linux
|
100
100
|
|
101
101
|
DEPENDENCIES
|
@@ -106,4 +106,4 @@ DEPENDENCIES
|
|
106
106
|
waterdrop!
|
107
107
|
|
108
108
|
BUNDLED WITH
|
109
|
-
2.3.
|
109
|
+
2.3.15
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# WaterDrop
|
2
2
|
|
3
|
-
**Note**: Documentation presented here refers to WaterDrop `2.
|
3
|
+
**Note**: Documentation presented here refers to WaterDrop `2.x`.
|
4
4
|
|
5
|
-
WaterDrop `2.
|
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
|
|
@@ -314,7 +314,7 @@ end
|
|
314
314
|
producer.monitor.subscribe(listener)
|
315
315
|
```
|
316
316
|
|
317
|
-
You can also find a ready to import DataDog dashboard configuration file that you can use to monitor all of your
|
317
|
+
You can also find [here](https://github.com/karafka/waterdrop/blob/master/lib/waterdrop/instrumentation/vendors/datadog/dashboard.json) a ready to import DataDog dashboard configuration file that you can use to monitor all of your producers.
|
318
318
|
|
319
319
|
### Error notifications
|
320
320
|
|
data/lib/waterdrop/config.rb
CHANGED
@@ -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
|
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,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
|
@@ -6,8 +6,8 @@ module WaterDrop
|
|
6
6
|
# It can be removed/replaced or anything without any harm to the Waterdrop flow
|
7
7
|
# @note It is a module as we can use it then as a part of the Karafka framework listener
|
8
8
|
# as well as we can use it standalone
|
9
|
-
class
|
10
|
-
# @param logger [Object]
|
9
|
+
class LoggerListener
|
10
|
+
# @param logger [Object] logger we want to use
|
11
11
|
def initialize(logger)
|
12
12
|
@logger = logger
|
13
13
|
end
|
@@ -10,7 +10,15 @@ module WaterDrop
|
|
10
10
|
# Adds a method that allows us to get the native kafka producer name
|
11
11
|
# @return [String] producer instance name
|
12
12
|
def name
|
13
|
-
|
13
|
+
unless @_native
|
14
|
+
version = ::Gem::Version.new(::Rdkafka::VERSION)
|
15
|
+
change = ::Gem::Version.new('0.12.0')
|
16
|
+
# 0.12.0 changed how the native producer client reference works.
|
17
|
+
# This code supports both older and newer versions of rdkafka
|
18
|
+
@_native = version >= change ? @client.native : @native_kafka
|
19
|
+
end
|
20
|
+
|
21
|
+
::Rdkafka::Bindings.rd_kafka_name(@_native)
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
data/lib/waterdrop/version.rb
CHANGED
data/lib/waterdrop.rb
CHANGED
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.2
|
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-
|
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
|
@@ -155,8 +144,8 @@ files:
|
|
155
144
|
- lib/waterdrop/instrumentation/callbacks/statistics.rb
|
156
145
|
- lib/waterdrop/instrumentation/callbacks/statistics_decorator.rb
|
157
146
|
- lib/waterdrop/instrumentation/callbacks_manager.rb
|
147
|
+
- lib/waterdrop/instrumentation/logger_listener.rb
|
158
148
|
- lib/waterdrop/instrumentation/monitor.rb
|
159
|
-
- lib/waterdrop/instrumentation/stdout_listener.rb
|
160
149
|
- lib/waterdrop/instrumentation/vendors/datadog/dashboard.json
|
161
150
|
- lib/waterdrop/instrumentation/vendors/datadog/listener.rb
|
162
151
|
- lib/waterdrop/patches/rdkafka/bindings.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.3.
|
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
|
-
|
1
|
+
-���m�E�ΕQQiPq�ǶKP k�]�N|�<�b^@�{�@�i�[��B��7މ_˘d�v;G�8%��Htic�D�U+
|