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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 192d0de743aeb1560eb55145d11b06c2f1f5ba61
4
- data.tar.gz: 145887b6c3313ad29f4eb88f9d17df62899a27c2
3
+ metadata.gz: b6f56ba47d6adce9b725e89c82f9d77763b87162
4
+ data.tar.gz: 923a2838012eb28fec495490887326786fbfbbb8
5
5
  SHA512:
6
- metadata.gz: b2a4cde46ea536888c90c4f2fb2611a7f4526840c2a422d85f99b646385b580e48f1eee92fc91c0422c1287d075d8e92530c80f060e0bdeb65cbace48276517f
7
- data.tar.gz: fdbb262b5620837f14d92986e12d946decd4b335665953ff7784151dcf6fafee8ba0843cbe14179d9a9e141cdbb2fdabe8ce187043ebc02db3d0ef0ac21787b0
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.6
1
+ 2.1.7
@@ -118,7 +118,7 @@ module Franz
118
118
  request.body = body
119
119
  @http.request(request)
120
120
  rescue EOFError, Errno::ECONNREFUSED, Errno::EPIPE
121
- log.warn event: 'output reconnect'
121
+ log.warn event: 'output dropped'
122
122
  open_uri
123
123
  sleep 1
124
124
  retry
@@ -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
- @kafka = Poseidon::Producer.new \
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
- loop do
68
+ until @stop
72
69
  @lock.synchronize do
73
- ready_messages = @messages
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: ready_messages.size
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
- @kafka.send_messages @messages
95
+ num_messages = kafka_send @messages
103
96
  log.debug \
104
97
  event: 'flush',
105
- num_messages: @messages.size
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: franz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer