waterdrop 0.2.1 → 0.3.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/CHANGELOG.md +3 -0
- data/Gemfile.lock +52 -72
- data/README.md +1 -0
- data/lib/water_drop/config.rb +1 -1
- data/lib/water_drop/message.rb +2 -5
- data/lib/water_drop/pool.rb +1 -1
- data/lib/water_drop/producer_proxy.rb +15 -36
- data/lib/water_drop/version.rb +1 -1
- data/lib/waterdrop.rb +1 -1
- data/waterdrop.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 787b506aa11e17d65df6abb198bbd86b750b95a8
|
|
4
|
+
data.tar.gz: 248d7a49d44adb5379940b64e7d5fd27b3821557
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b161ff34041a2471d19fea75d770c3f4e2eb1e5bdccd6ddca10863cc08444846c31aef795a3b69c779e239f1579e823326857ea78ab74d728570af69d0a0c397
|
|
7
|
+
data.tar.gz: 1713e4c8d7556c7d66d1ec76a848fcfbd8eb5b38ed7230f1b4518606f30232314a69915bf5bafc3a1bc8c038f267518bc23642e2d60293c810281e567d352845
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
waterdrop (0.
|
|
4
|
+
waterdrop (0.3.0)
|
|
5
5
|
bundler
|
|
6
6
|
connection_pool
|
|
7
7
|
null-logger
|
|
8
|
-
poseidon
|
|
9
8
|
rake
|
|
9
|
+
ruby-kafka
|
|
10
10
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
activesupport (= 4.2.5)
|
|
14
|
+
activemodel (4.2.6)
|
|
15
|
+
activesupport (= 4.2.6)
|
|
17
16
|
builder (~> 3.1)
|
|
18
|
-
activesupport (4.2.
|
|
17
|
+
activesupport (4.2.6)
|
|
19
18
|
i18n (~> 0.7)
|
|
20
19
|
json (~> 1.7, >= 1.7.7)
|
|
21
20
|
minitest (~> 5.1)
|
|
22
21
|
thread_safe (~> 0.3, >= 0.3.4)
|
|
23
22
|
tzinfo (~> 1.1)
|
|
24
|
-
|
|
25
|
-
ice_nine (~> 0.11.0)
|
|
26
|
-
memoizable (~> 0.4.0)
|
|
23
|
+
addressable (2.4.0)
|
|
27
24
|
ast (2.2.0)
|
|
28
|
-
astrolabe (1.3.1)
|
|
29
|
-
parser (~> 2.2)
|
|
30
25
|
axiom-types (0.1.1)
|
|
31
26
|
descendants_tracker (~> 0.0.4)
|
|
32
27
|
ice_nine (~> 0.11.0)
|
|
33
28
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
34
|
-
brakeman (3.1
|
|
29
|
+
brakeman (3.2.1)
|
|
35
30
|
erubis (~> 2.6)
|
|
36
|
-
fastercsv (~> 1.5)
|
|
37
31
|
haml (>= 3.0, < 5.0)
|
|
38
32
|
highline (>= 1.6.20, < 2.0)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ruby_parser (~> 3.7.0)
|
|
33
|
+
ruby2ruby (~> 2.3.0)
|
|
34
|
+
ruby_parser (~> 3.8.1)
|
|
42
35
|
safe_yaml (>= 1.0)
|
|
43
36
|
sass (~> 3.0)
|
|
44
37
|
slim (>= 1.3.6, < 4.0)
|
|
45
38
|
terminal-table (~> 1.4)
|
|
46
|
-
bson (4.0.
|
|
39
|
+
bson (4.0.4)
|
|
47
40
|
builder (3.2.2)
|
|
48
|
-
codeclimate-engine-rb (0.1
|
|
41
|
+
codeclimate-engine-rb (0.3.1)
|
|
49
42
|
virtus (~> 1.0)
|
|
50
|
-
coderay (1.1.
|
|
43
|
+
coderay (1.1.1)
|
|
51
44
|
coercible (1.0.0)
|
|
52
45
|
descendants_tracker (~> 0.0.1)
|
|
53
|
-
|
|
54
|
-
adamantium (~> 0.2.0)
|
|
55
|
-
equalizer (~> 0.0.9)
|
|
46
|
+
colorize (0.7.7)
|
|
56
47
|
connection_pool (2.2.0)
|
|
57
48
|
descendants_tracker (0.0.4)
|
|
58
49
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
@@ -60,10 +51,10 @@ GEM
|
|
|
60
51
|
docile (1.1.5)
|
|
61
52
|
equalizer (0.0.11)
|
|
62
53
|
erubis (2.7.0)
|
|
63
|
-
faker (1.6.
|
|
54
|
+
faker (1.6.3)
|
|
64
55
|
i18n (~> 0.5)
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
flay (2.7.0)
|
|
57
|
+
erubis (~> 2.7.0)
|
|
67
58
|
ruby_parser (~> 3.0)
|
|
68
59
|
sexp_processor (~> 4.0)
|
|
69
60
|
flog (4.3.2)
|
|
@@ -77,28 +68,27 @@ GEM
|
|
|
77
68
|
sysexits (~> 1.1)
|
|
78
69
|
highline (1.7.8)
|
|
79
70
|
i18n (0.7.0)
|
|
80
|
-
ice_nine (0.11.
|
|
71
|
+
ice_nine (0.11.2)
|
|
81
72
|
json (1.8.3)
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
launchy (2.4.3)
|
|
74
|
+
addressable (~> 2.3)
|
|
84
75
|
method_source (0.8.2)
|
|
85
|
-
minitest (5.8.
|
|
86
|
-
mongo (2.2.
|
|
76
|
+
minitest (5.8.4)
|
|
77
|
+
mongo (2.2.4)
|
|
87
78
|
bson (~> 4.0)
|
|
88
|
-
mongoid (5.
|
|
79
|
+
mongoid (5.1.1)
|
|
89
80
|
activemodel (~> 4.0)
|
|
90
81
|
mongo (~> 2.1)
|
|
91
|
-
origin (~> 2.
|
|
82
|
+
origin (~> 2.2)
|
|
92
83
|
tzinfo (>= 0.3.37)
|
|
93
84
|
mongoid-rspec (3.0.0)
|
|
94
85
|
mongoid (~> 5.0)
|
|
95
86
|
rake
|
|
96
87
|
rspec (~> 3.3)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ast (>= 1.1, < 3.0)
|
|
88
|
+
null-logger (0.1.1)
|
|
89
|
+
origin (2.2.0)
|
|
90
|
+
parser (2.3.0.6)
|
|
91
|
+
ast (~> 2.2)
|
|
102
92
|
polishgeeks-dev-tools (1.2.1)
|
|
103
93
|
brakeman
|
|
104
94
|
faker
|
|
@@ -112,64 +102,62 @@ GEM
|
|
|
112
102
|
simplecov
|
|
113
103
|
timecop
|
|
114
104
|
yard
|
|
115
|
-
poseidon (0.0.5)
|
|
116
105
|
powerpack (0.1.1)
|
|
117
|
-
private_attr (1.1.0)
|
|
118
|
-
procto (0.0.2)
|
|
119
106
|
pry (0.10.3)
|
|
120
107
|
coderay (~> 1.1.0)
|
|
121
108
|
method_source (~> 0.8.1)
|
|
122
109
|
slop (~> 3.4)
|
|
123
|
-
rainbow (2.
|
|
124
|
-
rake (
|
|
125
|
-
reek (3.
|
|
126
|
-
codeclimate-engine-rb (~> 0.1
|
|
127
|
-
parser (~> 2.
|
|
128
|
-
private_attr (~> 1.1)
|
|
110
|
+
rainbow (2.1.0)
|
|
111
|
+
rake (11.1.1)
|
|
112
|
+
reek (3.11)
|
|
113
|
+
codeclimate-engine-rb (~> 0.3.1)
|
|
114
|
+
parser (~> 2.3, >= 2.3.0.6)
|
|
129
115
|
rainbow (~> 2.0)
|
|
130
|
-
unparser (~> 0.2.2)
|
|
131
116
|
rspec (3.4.0)
|
|
132
117
|
rspec-core (~> 3.4.0)
|
|
133
118
|
rspec-expectations (~> 3.4.0)
|
|
134
119
|
rspec-mocks (~> 3.4.0)
|
|
135
|
-
rspec-core (3.4.
|
|
120
|
+
rspec-core (3.4.4)
|
|
136
121
|
rspec-support (~> 3.4.0)
|
|
137
122
|
rspec-expectations (3.4.0)
|
|
138
123
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
139
124
|
rspec-support (~> 3.4.0)
|
|
140
|
-
rspec-mocks (3.4.
|
|
125
|
+
rspec-mocks (3.4.1)
|
|
141
126
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
142
127
|
rspec-support (~> 3.4.0)
|
|
143
128
|
rspec-support (3.4.1)
|
|
144
|
-
rubocop (0.
|
|
145
|
-
|
|
146
|
-
parser (>= 2.2.3.0, < 3.0)
|
|
129
|
+
rubocop (0.38.0)
|
|
130
|
+
parser (>= 2.3.0.6, < 3.0)
|
|
147
131
|
powerpack (~> 0.1)
|
|
148
132
|
rainbow (>= 1.99.1, < 3.0)
|
|
149
133
|
ruby-progressbar (~> 1.7)
|
|
150
|
-
|
|
134
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
135
|
+
ruby-kafka (0.3.2)
|
|
151
136
|
ruby-progressbar (1.7.5)
|
|
152
|
-
ruby2ruby (2.
|
|
137
|
+
ruby2ruby (2.3.0)
|
|
153
138
|
ruby_parser (~> 3.1)
|
|
154
139
|
sexp_processor (~> 4.0)
|
|
155
|
-
ruby_parser (3.
|
|
140
|
+
ruby_parser (3.8.1)
|
|
156
141
|
sexp_processor (~> 4.1)
|
|
157
|
-
rubycritic (2.
|
|
158
|
-
|
|
142
|
+
rubycritic (2.8.0)
|
|
143
|
+
colorize
|
|
144
|
+
flay (= 2.7.0)
|
|
159
145
|
flog (= 4.3.2)
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
launchy (= 2.4.3)
|
|
147
|
+
parser (~> 2.3)
|
|
148
|
+
reek (= 3.11)
|
|
149
|
+
ruby_parser (~> 3.8)
|
|
162
150
|
virtus (~> 1.0)
|
|
163
151
|
safe_yaml (1.0.4)
|
|
164
|
-
sass (3.4.
|
|
165
|
-
sexp_processor (4.
|
|
152
|
+
sass (3.4.21)
|
|
153
|
+
sexp_processor (4.7.0)
|
|
166
154
|
shoulda (3.5.0)
|
|
167
155
|
shoulda-context (~> 1.0, >= 1.0.1)
|
|
168
156
|
shoulda-matchers (>= 1.4.1, < 3.0)
|
|
169
157
|
shoulda-context (1.2.1)
|
|
170
158
|
shoulda-matchers (2.8.0)
|
|
171
159
|
activesupport (>= 3.0.0)
|
|
172
|
-
simplecov (0.11.
|
|
160
|
+
simplecov (0.11.2)
|
|
173
161
|
docile (~> 1.1.0)
|
|
174
162
|
json (~> 1.8)
|
|
175
163
|
simplecov-html (~> 0.10.0)
|
|
@@ -182,19 +170,11 @@ GEM
|
|
|
182
170
|
temple (0.7.6)
|
|
183
171
|
terminal-table (1.5.2)
|
|
184
172
|
thread_safe (0.3.5)
|
|
185
|
-
tilt (2.0.
|
|
173
|
+
tilt (2.0.2)
|
|
186
174
|
timecop (0.8.0)
|
|
187
|
-
tins (1.6.0)
|
|
188
175
|
tzinfo (1.2.2)
|
|
189
176
|
thread_safe (~> 0.1)
|
|
190
|
-
|
|
191
|
-
abstract_type (~> 0.0.7)
|
|
192
|
-
adamantium (~> 0.2.0)
|
|
193
|
-
concord (~> 0.1.5)
|
|
194
|
-
diff-lcs (~> 1.2.5)
|
|
195
|
-
equalizer (~> 0.0.9)
|
|
196
|
-
parser (~> 2.2.2)
|
|
197
|
-
procto (~> 0.0.2)
|
|
177
|
+
unicode-display_width (1.0.2)
|
|
198
178
|
virtus (1.0.5)
|
|
199
179
|
axiom-types (~> 0.1)
|
|
200
180
|
coercible (~> 1.0)
|
data/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
[](https://travis-ci.org/karafka/waterdrop)
|
|
4
4
|
[](https://codeclimate.com/github/karafka/waterdrop)
|
|
5
5
|
[](http://badge.fury.io/rb/waterdrop)
|
|
6
|
+
[](https://gitter.im/karafka/karafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
6
7
|
|
|
7
8
|
Gem used to send messages to Kafka in an easy way.
|
|
8
9
|
|
data/lib/water_drop/config.rb
CHANGED
data/lib/water_drop/message.rb
CHANGED
|
@@ -21,11 +21,8 @@ module WaterDrop
|
|
|
21
21
|
def send!
|
|
22
22
|
return true unless ::WaterDrop.config.send_messages?
|
|
23
23
|
|
|
24
|
-
Pool.with
|
|
25
|
-
|
|
26
|
-
Poseidon::MessageToSend.new(topic, message)
|
|
27
|
-
])
|
|
28
|
-
end
|
|
24
|
+
Pool.with { |producer| producer.send_message(self) }
|
|
25
|
+
|
|
29
26
|
::WaterDrop.logger.info("Message #{message} was sent to topic '#{topic}'")
|
|
30
27
|
rescue StandardError => e
|
|
31
28
|
# Even if we dont reraise this exception, it should log that it happened
|
data/lib/water_drop/pool.rb
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
module WaterDrop
|
|
2
2
|
# Proxy object for a producer (sender) objects that are inside pool
|
|
3
3
|
# We use it to provide additional timeout monitoring layer
|
|
4
|
-
# There
|
|
5
|
-
# are old and not used - that's why we just
|
|
6
|
-
# the connection layer is not being used for too long
|
|
4
|
+
# There used to be an issue with Poseidon (previous engine for this lib)
|
|
5
|
+
# usage of sockets that are old and not used - that's why we just
|
|
6
|
+
# reinitialize connection if the connection layer is not being used for too long
|
|
7
|
+
# We keep this logic to avoid problems just in case. If those problems won't occure
|
|
8
|
+
# with Ruby-Kafka, we will drop it
|
|
7
9
|
class ProducerProxy
|
|
8
10
|
# How long should be object considered alive if nothing is being
|
|
9
11
|
# send using it. After that time, we will recreate the connection
|
|
10
12
|
LIFE_TIME = 5 * 60 # 5 minute
|
|
11
13
|
|
|
12
14
|
# If sending fails - how many times we should try with a new connection
|
|
13
|
-
# @note It works in a similar way to Poseidon internal max_send_retries option, but it will
|
|
14
|
-
# create a new connection after failure (Poseidon tries to use the same one)
|
|
15
15
|
MAX_SEND_RETRIES = 1
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
POSEIDON_PARAMS = {
|
|
19
|
-
metadata_refresh_interval_ms: 5 * 60 * 1000, # 5 minutes
|
|
20
|
-
# @see https://kafka.apache.org/08/configuration.html
|
|
21
|
-
# Security level for producer
|
|
22
|
-
required_acks: -1,
|
|
23
|
-
# @see https://issues.apache.org/jira/browse/KAFKA-1494
|
|
24
|
-
retry_backoff_ms: 1000,
|
|
25
|
-
max_send_retries: 1
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
# @return [WaterDrop::ProducerProxy] proxy object to Poseidon::Producer
|
|
17
|
+
# @return [WaterDrop::ProducerProxy] proxy object to Kafka::Producer
|
|
29
18
|
# @note To ignore @last_usage nil case - we just assume that it is being
|
|
30
19
|
# first used when we create it
|
|
31
20
|
def initialize
|
|
@@ -33,17 +22,16 @@ module WaterDrop
|
|
|
33
22
|
@attempts = 0
|
|
34
23
|
end
|
|
35
24
|
|
|
36
|
-
# Sends
|
|
37
|
-
# @param
|
|
38
|
-
# @return [Boolean] were the messages send
|
|
39
|
-
# @note Even if you send one message - it still needs to be in an array
|
|
25
|
+
# Sends message to Kafka
|
|
26
|
+
# @param message [WaterDrop::Message] message that we want to send
|
|
40
27
|
# @note If something goes wrong it will assume that producer is corrupted and will try to
|
|
41
28
|
# create a new one
|
|
42
29
|
# @example Send 1 message
|
|
43
|
-
# ProducerProxy.new.
|
|
44
|
-
def
|
|
30
|
+
# ProducerProxy.new.send_message(WaterDrop::Message.new(topic, message))
|
|
31
|
+
def send_message(message)
|
|
45
32
|
touch
|
|
46
|
-
producer.
|
|
33
|
+
producer.produce(message.message, topic: message.topic)
|
|
34
|
+
producer.deliver_messages
|
|
47
35
|
rescue StandardError => e
|
|
48
36
|
reload!
|
|
49
37
|
|
|
@@ -61,20 +49,10 @@ module WaterDrop
|
|
|
61
49
|
@last_usage = Time.now
|
|
62
50
|
end
|
|
63
51
|
|
|
64
|
-
# @return [
|
|
52
|
+
# @return [Kafka::Producer] producer instance to which we can forward method requests
|
|
65
53
|
def producer
|
|
66
54
|
reload! if dead?
|
|
67
|
-
|
|
68
|
-
@producer ||= Poseidon::Producer.new(
|
|
69
|
-
::WaterDrop.config.kafka_hosts,
|
|
70
|
-
producer_id,
|
|
71
|
-
POSEIDON_PARAMS
|
|
72
|
-
)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# @return [String] random unique id for producer
|
|
76
|
-
def producer_id
|
|
77
|
-
object_id.to_s + Time.now.to_f.to_s
|
|
55
|
+
@producer ||= Kafka.new(seed_brokers: ::WaterDrop.config.kafka_hosts).producer
|
|
78
56
|
end
|
|
79
57
|
|
|
80
58
|
# @return [Boolean] true if we cannot use producer anymore because it was not used for a
|
|
@@ -85,6 +63,7 @@ module WaterDrop
|
|
|
85
63
|
|
|
86
64
|
# Resets a producer so a new one will be created once requested
|
|
87
65
|
def reload!
|
|
66
|
+
@producer.shutdown if @producer
|
|
88
67
|
@producer = nil
|
|
89
68
|
end
|
|
90
69
|
end
|
data/lib/water_drop/version.rb
CHANGED
data/lib/waterdrop.rb
CHANGED
data/waterdrop.gemspec
CHANGED
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
|
|
17
17
|
spec.add_dependency 'bundler', '>= 0'
|
|
18
18
|
spec.add_dependency 'rake', '>= 0'
|
|
19
|
-
spec.add_dependency '
|
|
19
|
+
spec.add_dependency 'ruby-kafka', '>= 0'
|
|
20
20
|
spec.add_dependency 'connection_pool', '>= 0'
|
|
21
21
|
spec.add_dependency 'null-logger'
|
|
22
22
|
|
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.3.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: 2016-
|
|
12
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -40,7 +40,7 @@ dependencies:
|
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
|
-
name:
|
|
43
|
+
name: ruby-kafka
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
46
|
- - ">="
|