waterdrop 0.3.2 → 0.3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/Gemfile.lock +7 -4
- data/README.md +3 -3
- data/lib/water_drop.rb +1 -0
- data/lib/water_drop/config.rb +19 -26
- data/lib/water_drop/message.rb +2 -2
- data/lib/water_drop/producer_proxy.rb +1 -1
- data/lib/water_drop/version.rb +1 -1
- data/waterdrop.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8ac470555284f98026eafbe5e1d19e0feb9c3dd
|
4
|
+
data.tar.gz: 4d81437a65a107354a0891a872a6fd865e87cbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665b6bb116db059a75f94b27bf7b2e33d09ec3854713f76ebf7c83a850ed47c419a41bccec4dbb431cc2d7d0f82b71092e3ffd9db1064fd40e0decd13eb3e42b
|
7
|
+
data.tar.gz: 7c21c6c9e54da94b7a01f32090f86075cc976a937f84f44bc5e978806748a84c3856140ac81af207856d536e1f91278bb91cc26d45032e068ee8a47ef8c72172
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waterdrop (0.3.2)
|
4
|
+
waterdrop (0.3.2.1)
|
5
5
|
bundler
|
6
6
|
connection_pool
|
7
|
+
dry-configurable (~> 0.1.7)
|
7
8
|
null-logger
|
8
9
|
rake
|
9
10
|
ruby-kafka
|
@@ -38,6 +39,8 @@ GEM
|
|
38
39
|
thread_safe (~> 0.3, >= 0.3.1)
|
39
40
|
diff-lcs (1.2.5)
|
40
41
|
docile (1.1.5)
|
42
|
+
dry-configurable (0.1.7)
|
43
|
+
concurrent-ruby (~> 1.0)
|
41
44
|
equalizer (0.0.11)
|
42
45
|
erubis (2.7.0)
|
43
46
|
faker (1.6.6)
|
@@ -65,7 +68,7 @@ GEM
|
|
65
68
|
addressable (~> 2.3)
|
66
69
|
method_source (0.8.2)
|
67
70
|
minitest (5.9.0)
|
68
|
-
null-logger (0.1.
|
71
|
+
null-logger (0.1.3)
|
69
72
|
parser (2.3.1.2)
|
70
73
|
ast (~> 2.2)
|
71
74
|
path_expander (1.0.0)
|
@@ -115,7 +118,7 @@ GEM
|
|
115
118
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
116
119
|
rubocop-rspec (1.5.1)
|
117
120
|
rubocop (>= 0.41.2)
|
118
|
-
ruby-kafka (0.3.
|
121
|
+
ruby-kafka (0.3.15)
|
119
122
|
ruby-progressbar (1.8.1)
|
120
123
|
ruby_parser (3.8.2)
|
121
124
|
sexp_processor (~> 4.1)
|
@@ -164,4 +167,4 @@ DEPENDENCIES
|
|
164
167
|
waterdrop!
|
165
168
|
|
166
169
|
BUNDLED WITH
|
167
|
-
1.
|
170
|
+
1.12.5
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ WaterDrop has following configuration options:
|
|
32
32
|
| Option | Value type | Description |
|
33
33
|
|-------------------------|---------------|----------------------------------|
|
34
34
|
| send_messages | Boolean | Should we send messages to Kafka |
|
35
|
-
|
|
35
|
+
| kafka.hosts | Array<String> | Kafka servers hosts with ports |
|
36
36
|
| connection_pool_size | Integer | Kafka connection pool size |
|
37
37
|
| connection_pool_timeout | Integer | Kafka connection pool timeout |
|
38
38
|
| raise_on_failure | Boolean | Should we raise an exception when we cannot send message to Kafka - if false will silently ignore failures (will just ignore them) |
|
@@ -44,7 +44,7 @@ WaterDrop.setup do |config|
|
|
44
44
|
config.send_messages = true
|
45
45
|
config.connection_pool_size = 20
|
46
46
|
config.connection_pool_timeout = 1
|
47
|
-
config.
|
47
|
+
config.kafka.hosts = ['localhost:9092']
|
48
48
|
config.raise_on_failure = true
|
49
49
|
end
|
50
50
|
```
|
@@ -56,7 +56,7 @@ WaterDrop.setup do |config|
|
|
56
56
|
config.send_messages = Rails.env.production?
|
57
57
|
config.connection_pool_size = 20
|
58
58
|
config.connection_pool_timeout = 1
|
59
|
-
config.
|
59
|
+
config.kafka.hosts = [Rails.env.production? ? 'prod-host:9091' : 'localhost:9092']
|
60
60
|
config.raise_on_failure = Rails.env.production?
|
61
61
|
end
|
62
62
|
```
|
data/lib/water_drop.rb
CHANGED
data/lib/water_drop/config.rb
CHANGED
@@ -1,40 +1,33 @@
|
|
1
1
|
module WaterDrop
|
2
2
|
# Configurator for setting up all options required by WaterDrop
|
3
3
|
class Config
|
4
|
-
|
5
|
-
attr_accessor :config
|
6
|
-
end
|
4
|
+
extend Dry::Configurable
|
7
5
|
|
8
6
|
# Available options
|
9
|
-
# @option connection_pool_size [Fixnum] The number of connections to pool.
|
10
7
|
# @option connection_pool_timeout [Fixnum] Amount of time in seconds to wait for a connection
|
11
8
|
# if none currently available.
|
12
|
-
|
9
|
+
setting :connection_pool_timeout
|
13
10
|
# @option send_messages [Boolean] boolean value to define whether messages should be sent
|
11
|
+
setting :send_messages
|
14
12
|
# @option raise_on_failure [Boolean] Should raise error when failed to deliver a message
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
OPTIONS.each do |attr_name|
|
24
|
-
attr_accessor attr_name
|
25
|
-
|
26
|
-
# @return [Boolean] is given command enabled
|
27
|
-
define_method :"#{attr_name}?" do
|
28
|
-
public_send(attr_name) == true
|
29
|
-
end
|
13
|
+
setting :raise_on_failure
|
14
|
+
# @option connection_pool_size [Fixnum] The number of connections to pool.
|
15
|
+
setting :connection_pool_size
|
16
|
+
# option kafka [Hash] - optional - kafka configuration options (hosts)
|
17
|
+
setting :kafka do
|
18
|
+
# @option hosts [Array<String>] Array that contains Kafka hosts with ports
|
19
|
+
setting :hosts
|
30
20
|
end
|
31
21
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
22
|
+
class << self
|
23
|
+
# Configurating method
|
24
|
+
# @yield Runs a block of code providing a config singleton instance to it
|
25
|
+
# @yieldparam [WaterDrop::Config] WaterDrop config instance
|
26
|
+
def setup
|
27
|
+
configure do |config|
|
28
|
+
yield(config)
|
29
|
+
end
|
30
|
+
end
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
data/lib/water_drop/message.rb
CHANGED
@@ -21,7 +21,7 @@ module WaterDrop
|
|
21
21
|
# @example Set a message
|
22
22
|
# WaterDrop::Message.new(topic, message).send!
|
23
23
|
def send!
|
24
|
-
return true unless ::WaterDrop.config.send_messages
|
24
|
+
return true unless ::WaterDrop.config.send_messages
|
25
25
|
|
26
26
|
Pool.with { |producer| producer.send_message(self) }
|
27
27
|
|
@@ -31,7 +31,7 @@ module WaterDrop
|
|
31
31
|
::WaterDrop.logger.error(e)
|
32
32
|
# Reraise if we want to raise on failure
|
33
33
|
# Ignore if we dont want to know that something went wrong
|
34
|
-
return unless ::WaterDrop.config.raise_on_failure
|
34
|
+
return unless ::WaterDrop.config.raise_on_failure
|
35
35
|
raise(e)
|
36
36
|
end
|
37
37
|
end
|
@@ -54,7 +54,7 @@ module WaterDrop
|
|
54
54
|
# @return [Kafka::Producer] producer instance to which we can forward method requests
|
55
55
|
def producer
|
56
56
|
reload! if dead?
|
57
|
-
@producer ||= Kafka.new(seed_brokers: ::WaterDrop.config.
|
57
|
+
@producer ||= Kafka.new(seed_brokers: ::WaterDrop.config.kafka.hosts).producer
|
58
58
|
end
|
59
59
|
|
60
60
|
# @return [Boolean] true if we cannot use producer anymore because it was not used for a
|
data/lib/water_drop/version.rb
CHANGED
data/waterdrop.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency 'ruby-kafka', '>= 0'
|
20
20
|
spec.add_dependency 'connection_pool', '>= 0'
|
21
21
|
spec.add_dependency 'null-logger'
|
22
|
+
spec.add_dependency 'dry-configurable', '~> 0.1.7'
|
22
23
|
spec.required_ruby_version = '>= 2.2.0'
|
23
24
|
|
24
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
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.3.2
|
4
|
+
version: 0.3.2.1
|
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: 2016-
|
12
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: dry-configurable
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.1.7
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.1.7
|
84
98
|
description: Kafka messaging made easy!
|
85
99
|
email:
|
86
100
|
- maciej@mensfeld.pl
|