waterdrop 0.3.2.4 → 0.4.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/.rspec +0 -3
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +7 -3
- data/README.md +24 -16
- data/Rakefile +1 -0
- data/lib/water_drop/config.rb +46 -16
- data/lib/water_drop/pool.rb +2 -2
- data/lib/water_drop/producer_proxy.rb +8 -7
- data/lib/water_drop/version.rb +1 -1
- data/waterdrop.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ebd8fb5186e625ad83a4039b1953e145e6ed6e
|
4
|
+
data.tar.gz: 3f5b6e5d6ac383388a4fff4d18f6600122e91bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ffc2c7b34e2e9f53b61db43de61fe5f557af524ffba98f1101a1a630d5af021d90d76e0d65a0c06a2d13114933240d9f984d0b359251ac58af84e2afff04320
|
7
|
+
data.tar.gz: d1617c0169e356b16332d9b70285e58f0b524185ca2cc413903d53316f379bf1a58a1d383c990883cb2eb827194a6c9d2959d3459a3f04f99548c3c2d5394f47
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# WaterDrop changelog
|
2
2
|
|
3
|
+
## 0.4 unreleased
|
4
|
+
- Bump to match Karafka
|
5
|
+
- Renamed ```hosts``` to ```seed_brokers```
|
6
|
+
- Removed the ```ssl``` scoping for ```kafka``` config namespace to better match Karafka conventions
|
7
|
+
- Added ```client_id``` option on a root config level
|
8
|
+
- Added ```logger``` option on a root config level
|
9
|
+
- Auto Propagation of config down to ruby-kafka
|
10
|
+
|
3
11
|
## 0.3.2
|
4
12
|
- Removed support for Ruby 2.1.*
|
5
13
|
- ~~Ruby 2.3.3 as default~~
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waterdrop (0.
|
4
|
+
waterdrop (0.4.0)
|
5
5
|
bundler
|
6
6
|
connection_pool
|
7
7
|
dry-configurable (~> 0.6)
|
8
8
|
null-logger
|
9
9
|
rake
|
10
|
-
ruby-kafka
|
10
|
+
ruby-kafka (~> 0.4)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
@@ -18,6 +18,9 @@ GEM
|
|
18
18
|
docile (1.1.5)
|
19
19
|
dry-configurable (0.7.0)
|
20
20
|
concurrent-ruby (~> 1.0)
|
21
|
+
ffi (1.9.18)
|
22
|
+
gssapi (1.2.0)
|
23
|
+
ffi (>= 1.0.1)
|
21
24
|
json (2.1.0)
|
22
25
|
null-logger (0.1.4)
|
23
26
|
rake (12.0.0)
|
@@ -34,7 +37,8 @@ GEM
|
|
34
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
38
|
rspec-support (~> 3.6.0)
|
36
39
|
rspec-support (3.6.0)
|
37
|
-
ruby-kafka (0.
|
40
|
+
ruby-kafka (0.4.0)
|
41
|
+
gssapi (>= 1.2.0)
|
38
42
|
simplecov (0.14.1)
|
39
43
|
docile (~> 1.1.0)
|
40
44
|
json (>= 1.8, < 3)
|
data/README.md
CHANGED
@@ -29,25 +29,33 @@ bundle install
|
|
29
29
|
|
30
30
|
WaterDrop has following configuration options:
|
31
31
|
|
32
|
-
| Option
|
33
|
-
|
34
|
-
| send_messages
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| kafka.
|
40
|
-
|
|
41
|
-
| kafka.
|
32
|
+
| Option | Required | Value type | Description |
|
33
|
+
|-----------------------------|------------|---------------|------------------------------------------------------------------------------------|
|
34
|
+
| send_messages | true | Boolean | Should we send messages to Kafka |
|
35
|
+
| connect_timeout | false | Integer | Number of seconds to wait while connecting to a broker for the first time |
|
36
|
+
| socket_timeout | false | Integer | Number of seconds to wait when reading from or writing to a socket |
|
37
|
+
| connection_pool.size | true | Integer | Kafka connection pool size |
|
38
|
+
| connection_pool.timeout | true | Integer | Kafka connection pool timeout |
|
39
|
+
| kafka.seed_brokers | true | Array<String> | Kafka servers hosts with ports |
|
40
|
+
| raise_on_failure | true | Boolean | Should we raise an exception when we cannot send message to Kafka - if false will silently ignore failures |
|
41
|
+
| kafka.ssl_ca_cert | false | String | SSL CA certificate |
|
42
|
+
| kafka.ssl_ca_cert_file_path | false | String | SSL CA certificate file path |
|
43
|
+
| kafka.ssl_client_cert | false | String | SSL client certificate |
|
44
|
+
| kafka.ssl_client_cert_key | false | String | SSL client certificate password |
|
45
|
+
| kafka.sasl_gssapi_principal | false | String | SASL principal |
|
46
|
+
| kafka.sasl_gssapi_keytab | false | String | SASL keytab |
|
47
|
+
| kafka.sasl_plain_authzid | false | String | The authorization identity to use |
|
48
|
+
| kafka.sasl_plain_username | false | String | The username used to authenticate |
|
49
|
+
| kafka.sasl_plain_password | false | String | The password used to authenticate |
|
42
50
|
|
43
51
|
To apply this configuration, you need to use a *setup* method:
|
44
52
|
|
45
53
|
```ruby
|
46
54
|
WaterDrop.setup do |config|
|
47
55
|
config.send_messages = true
|
48
|
-
config.
|
49
|
-
config.
|
50
|
-
config.kafka.
|
56
|
+
config.connection_pool.size = 20
|
57
|
+
config.connection_pool.timeout = 1
|
58
|
+
config.kafka.seed_brokers = ['localhost:9092']
|
51
59
|
config.raise_on_failure = true
|
52
60
|
end
|
53
61
|
```
|
@@ -57,9 +65,9 @@ This configuration can be placed in *config/initializers* and can vary based on
|
|
57
65
|
```ruby
|
58
66
|
WaterDrop.setup do |config|
|
59
67
|
config.send_messages = Rails.env.production?
|
60
|
-
config.
|
61
|
-
config.
|
62
|
-
config.kafka.
|
68
|
+
config.connection_pool.size = 20
|
69
|
+
config.connection_pool.timeout = 1
|
70
|
+
config.kafka.seed_brokers = [Rails.env.production? ? 'prod-host:9091' : 'localhost:9092']
|
63
71
|
config.raise_on_failure = Rails.env.production?
|
64
72
|
end
|
65
73
|
```
|
data/Rakefile
CHANGED
data/lib/water_drop/config.rb
CHANGED
@@ -5,29 +5,59 @@ module WaterDrop
|
|
5
5
|
class Config
|
6
6
|
extend Dry::Configurable
|
7
7
|
|
8
|
+
# option client_id [String] identifier of this producer
|
9
|
+
setting :client_id, 'waterdrop'
|
10
|
+
# option logger [Instance, nil] logger that we want to use or nil to
|
11
|
+
# fallback to ruby-kafka logger
|
12
|
+
setting :logger, nil
|
8
13
|
# Available options
|
9
|
-
# @option connection_pool_timeout [Fixnum] Amount of time in seconds to wait for a connection
|
10
|
-
# if none currently available.
|
11
|
-
setting :connection_pool_timeout
|
12
|
-
# @option send_messages [Boolean] boolean value to define whether messages should be sent
|
13
14
|
setting :send_messages
|
14
15
|
# @option raise_on_failure [Boolean] Should raise error when failed to deliver a message
|
15
16
|
setting :raise_on_failure
|
16
|
-
|
17
|
-
|
17
|
+
|
18
|
+
# Connection pool options
|
19
|
+
setting :connection_pool do
|
20
|
+
# Connection pool size for producers. Note that we take a bigger number because there
|
21
|
+
# are cases when we might have more sidekiq threads than Karafka consumers (small app)
|
22
|
+
# or the opposite for bigger systems
|
23
|
+
setting :size, 2
|
24
|
+
# How long should we wait for a working resource from the pool before rising timeout
|
25
|
+
# With a proper connection pool size, this should never happen
|
26
|
+
setting :timeout, 5
|
27
|
+
end
|
28
|
+
|
18
29
|
# option kafka [Hash] - optional - kafka configuration options (hosts)
|
19
30
|
setting :kafka do
|
20
|
-
# @option
|
21
|
-
setting :
|
31
|
+
# @option seed_brokers [Array<String>] Array that contains Kafka seed broker hosts with ports
|
32
|
+
setting :seed_brokers
|
33
|
+
# option connect_timeout [Integer] Sets the number of seconds to wait while connecting to
|
34
|
+
# a broker for the first time. When ruby-kafka initializes, it needs to connect to at
|
35
|
+
# least one host.
|
36
|
+
setting :connect_timeout, 10
|
37
|
+
# option socket_timeout [Integer] Sets the number of seconds to wait when reading from or
|
38
|
+
# writing to a socket connection to a broker. After this timeout expires the connection
|
39
|
+
# will be killed. Note that some Kafka operations are by definition long-running, such as
|
40
|
+
# waiting for new messages to arrive in a partition, so don't set this value too low
|
41
|
+
setting :socket_timeout, 10
|
22
42
|
# SSL authentication related settings
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
43
|
+
# option ca_cert [String] SSL CA certificate
|
44
|
+
setting :ssl_ca_cert, nil
|
45
|
+
# option ssl_ca_cert_file_path [String] SSL CA certificate file path
|
46
|
+
setting :ssl_ca_cert_file_path, nil
|
47
|
+
# option client_cert [String] SSL client certificate
|
48
|
+
setting :ssl_client_cert, nil
|
49
|
+
# option client_cert_key [String] SSL client certificate password
|
50
|
+
setting :ssl_client_cert_key, nil
|
51
|
+
# option sasl_gssapi_principal [String] sasl principal
|
52
|
+
setting :sasl_gssapi_principal, nil
|
53
|
+
# option sasl_gssapi_keytab [String] sasl keytab
|
54
|
+
setting :sasl_gssapi_keytab, nil
|
55
|
+
# option sasl_plain_authzid [String] The authorization identity to use
|
56
|
+
setting :sasl_plain_authzid, ''
|
57
|
+
# option sasl_plain_username [String] The username used to authenticate
|
58
|
+
setting :sasl_plain_username, nil
|
59
|
+
# option sasl_plain_password [String] The password used to authenticate
|
60
|
+
setting :sasl_plain_password, nil
|
31
61
|
end
|
32
62
|
|
33
63
|
class << self
|
data/lib/water_drop/pool.rb
CHANGED
@@ -11,8 +11,8 @@ module WaterDrop
|
|
11
11
|
# @return [::ConnectionPool] connection pool instance that we can then use
|
12
12
|
def pool
|
13
13
|
@pool ||= ConnectionPool.new(
|
14
|
-
size: ::WaterDrop.config.
|
15
|
-
timeout: ::WaterDrop.config.
|
14
|
+
size: ::WaterDrop.config.connection_pool.size,
|
15
|
+
timeout: ::WaterDrop.config.connection_pool.timeout
|
16
16
|
) do
|
17
17
|
WaterDrop::ProducerProxy.new
|
18
18
|
end
|
@@ -32,9 +32,10 @@ module WaterDrop
|
|
32
32
|
# ProducerProxy.new.send_message(WaterDrop::Message.new(topic, message))
|
33
33
|
def send_message(message)
|
34
34
|
touch
|
35
|
-
producer.produce(
|
36
|
-
|
37
|
-
|
35
|
+
producer.produce(
|
36
|
+
message.message,
|
37
|
+
{ topic: message.topic }.merge(message.options)
|
38
|
+
)
|
38
39
|
producer.deliver_messages
|
39
40
|
rescue StandardError => e
|
40
41
|
reload!
|
@@ -57,10 +58,10 @@ module WaterDrop
|
|
57
58
|
def producer
|
58
59
|
reload! if dead?
|
59
60
|
@producer ||= Kafka.new(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
{
|
62
|
+
client_id: ::WaterDrop.config.client_id,
|
63
|
+
logger: ::WaterDrop.config.logger
|
64
|
+
}.merge(::WaterDrop.config.kafka.to_h)
|
64
65
|
).producer
|
65
66
|
end
|
66
67
|
|
data/lib/water_drop/version.rb
CHANGED
data/waterdrop.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_dependency 'bundler', '>= 0'
|
20
20
|
spec.add_dependency 'rake', '>= 0'
|
21
|
-
spec.add_dependency 'ruby-kafka', '
|
21
|
+
spec.add_dependency 'ruby-kafka', '~> 0.4'
|
22
22
|
spec.add_dependency 'connection_pool', '>= 0'
|
23
23
|
spec.add_dependency 'null-logger'
|
24
24
|
spec.add_dependency 'dry-configurable', '~> 0.6'
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: ruby-kafka
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
48
|
+
version: '0.4'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
55
|
+
version: '0.4'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: connection_pool
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|