franz 2.1.6 → 2.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +1 -0
- data/VERSION +1 -1
- data/lib/franz/output/http.rb +1 -1
- data/lib/franz/output/kafka.rb +30 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f56ba47d6adce9b725e89c82f9d77763b87162
|
4
|
+
data.tar.gz: 923a2838012eb28fec495490887326786fbfbbb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd5ce1689ecdd4667476b11ff74540bc4f262fec7959c4b9c6b1d488809e3f33e1277e51b05d4aa33ef4c851e364d51dab9c05d1478c966c0b9c22033234486b
|
7
|
+
data.tar.gz: 9985397b685ae376718dca6ba2802367ec1c7dc8d8b856e777bd630f0f4053681713d067d783af9b5f486e53ce6692612ce91df576f3e69e26d6f2c38340d342
|
data/Readme.md
CHANGED
@@ -232,6 +232,7 @@ for Chef.
|
|
232
232
|
- Running Franz without arguments now prints help text (i.e. `--config` is now required)
|
233
233
|
- Rename `StdOut` to `Device`, no longer experimental
|
234
234
|
- Allow single state file if no glob is used
|
235
|
+
- Add autoreconnect logic to `Kafka` output
|
235
236
|
- Handle `EACCESS` on `IO.read` gracefully
|
236
237
|
- New `HTTP` output (experimental)
|
237
238
|
- Remove default line limit
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.7
|
data/lib/franz/output/http.rb
CHANGED
data/lib/franz/output/kafka.rb
CHANGED
@@ -52,30 +52,25 @@ module Franz
|
|
52
52
|
@flush_interval = opts[:output].delete :flush_interval
|
53
53
|
@topic = opts[:output].delete :topic
|
54
54
|
|
55
|
-
kafka_brokers = opts[:output].delete(:brokers) || %w[ localhost:9092 ]
|
56
|
-
kafka_client_id = opts[:output].delete :client_id
|
57
|
-
kafka_config = opts[:output].map { |k,v|
|
55
|
+
@kafka_brokers = opts[:output].delete(:brokers) || %w[ localhost:9092 ]
|
56
|
+
@kafka_client_id = opts[:output].delete :client_id
|
57
|
+
@kafka_config = opts[:output].map { |k,v|
|
58
58
|
[ k, v.is_a?(String) ? v.to_sym : v ]
|
59
59
|
}
|
60
60
|
|
61
|
-
|
62
|
-
kafka_brokers,
|
63
|
-
kafka_client_id,
|
64
|
-
Hash[kafka_config]
|
61
|
+
kafka_connect
|
65
62
|
|
66
63
|
@lock = Mutex.new
|
67
64
|
@messages = []
|
68
65
|
|
69
66
|
|
70
67
|
@thread = Thread.new do
|
71
|
-
|
68
|
+
until @stop
|
72
69
|
@lock.synchronize do
|
73
|
-
|
74
|
-
@messages = []
|
75
|
-
@kafka.send_messages ready_messages unless ready_messages.empty?
|
70
|
+
num_messages = kafka_send @messages
|
76
71
|
log.debug \
|
77
72
|
event: 'periodic flush',
|
78
|
-
num_messages:
|
73
|
+
num_messages: num_messages
|
79
74
|
end
|
80
75
|
|
81
76
|
sleep @flush_interval
|
@@ -96,14 +91,11 @@ module Franz
|
|
96
91
|
@lock.synchronize do
|
97
92
|
@messages << Poseidon::MessageToSend.new(@topic, payload)
|
98
93
|
|
99
|
-
@statz.inc :num_output
|
100
|
-
|
101
94
|
if @messages.size >= @flush_size
|
102
|
-
|
95
|
+
num_messages = kafka_send @messages
|
103
96
|
log.debug \
|
104
97
|
event: 'flush',
|
105
|
-
num_messages:
|
106
|
-
@messages = []
|
98
|
+
num_messages: num_messages
|
107
99
|
end
|
108
100
|
end
|
109
101
|
|
@@ -136,6 +128,27 @@ module Franz
|
|
136
128
|
private
|
137
129
|
def log ; @logger end
|
138
130
|
|
131
|
+
def kafka_connect
|
132
|
+
@kafka = Poseidon::Producer.new \
|
133
|
+
@kafka_brokers,
|
134
|
+
@kafka_client_id,
|
135
|
+
Hash[@kafka_config]
|
136
|
+
end
|
137
|
+
|
138
|
+
def kafka_send messages
|
139
|
+
return 0 if @messages.empty?
|
140
|
+
@kafka.send_messages @messages
|
141
|
+
@statz.inc :num_output, @messages.length
|
142
|
+
size = @messages.size
|
143
|
+
@messages = []
|
144
|
+
return size
|
145
|
+
rescue Poseidon::Errors::UnableToFetchMetadata
|
146
|
+
log.warn event: 'output dropped'
|
147
|
+
kafka_connect
|
148
|
+
sleep 1
|
149
|
+
retry
|
150
|
+
end
|
151
|
+
|
139
152
|
end
|
140
153
|
end
|
141
154
|
end
|