codeclimate-poseidon 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poseidon.rb +3 -0
- data/lib/poseidon/connection.rb +9 -1
- data/lib/poseidon/sync_producer.rb +1 -1
- data/lib/poseidon/version.rb +1 -1
- data/spec/unit/producer_spec.rb +1 -1
- data/spec/unit/protocol_spec.rb +1 -1
- data/spec/unit/sync_producer_spec.rb +1 -1
- 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: aa02e321bdedaf1f2ab107fa19baa839f8b8975e
|
4
|
+
data.tar.gz: 6be2d71921b325c65013edaa05f4be605f67bf61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343ba22d428d48fb50daecf1ba728be6add2918a0ae7c5fc6df477efb61de63e8f8c2d23d67d95a9aec7e1e65ee0646871ad532f274b74943d8a3c0f032b9e9c
|
7
|
+
data.tar.gz: e75c0e4afff8b28bd50a0ed331727c7f3d432907257616f9cab8ec95b802c5520dbeb80c3159ea6a99b4be54671a71944d930242e39442d7a0f50193e37fb6b4
|
data/lib/poseidon.rb
CHANGED
@@ -62,6 +62,9 @@ module Poseidon
|
|
62
62
|
10 => MessageSizeTooLarge
|
63
63
|
}
|
64
64
|
|
65
|
+
# Raised when messages were not successfully produced to Kafka
|
66
|
+
class MessageDeliveryError < StandardError; end
|
67
|
+
|
65
68
|
# Raised when a custom partitioner tries to send
|
66
69
|
# a message to a partition that doesn't exist.
|
67
70
|
class InvalidPartitionError < StandardError; end
|
data/lib/poseidon/connection.rb
CHANGED
@@ -11,6 +11,14 @@ module Poseidon
|
|
11
11
|
API_VERSION = 0
|
12
12
|
REPLICA_ID = -1 # Replica id is always -1 for non-brokers
|
13
13
|
|
14
|
+
REQUEST_CONNECTION_ERRORS = [
|
15
|
+
Errno::ECONNRESET,
|
16
|
+
Errno::EHOSTUNREACH,
|
17
|
+
Errno::EPIPE,
|
18
|
+
Errno::ETIMEDOUT,
|
19
|
+
TimeoutException,
|
20
|
+
].freeze
|
21
|
+
|
14
22
|
# @yieldparam [Connection]
|
15
23
|
def self.open(host, port, client_id, socket_timeout_ms, &block)
|
16
24
|
connection = new(host, port, client_id, socket_timeout_ms)
|
@@ -135,7 +143,7 @@ module Poseidon
|
|
135
143
|
buffer = Protocol::RequestBuffer.new
|
136
144
|
request.write(buffer)
|
137
145
|
ensure_write_or_timeout([buffer.to_s.bytesize].pack("N") + buffer.to_s)
|
138
|
-
rescue
|
146
|
+
rescue *REQUEST_CONNECTION_ERRORS => ex
|
139
147
|
@socket = nil
|
140
148
|
raise_connection_failed_from_exception(ex)
|
141
149
|
end
|
@@ -65,7 +65,7 @@ module Poseidon
|
|
65
65
|
end
|
66
66
|
|
67
67
|
if messages_to_send.pending_messages?
|
68
|
-
raise "Failed to send all messages: #{messages_to_send.messages} remaining"
|
68
|
+
raise Errors::MessageDeliveryError, "Failed to send all messages: #{messages_to_send.messages} remaining"
|
69
69
|
else
|
70
70
|
true
|
71
71
|
end
|
data/lib/poseidon/version.rb
CHANGED
data/spec/unit/producer_spec.rb
CHANGED
data/spec/unit/protocol_spec.rb
CHANGED
@@ -49,6 +49,6 @@ RSpec.describe "objects with errors" do
|
|
49
49
|
[partition_fetch_response])
|
50
50
|
response = FetchResponse.new(double('common'), [topic_fetch_response])
|
51
51
|
|
52
|
-
expect { response.raise_error_if_one_exists }.to raise_error
|
52
|
+
expect { response.raise_error_if_one_exists }.to raise_error(Poseidon::Errors::LeaderNotAvailable)
|
53
53
|
end
|
54
54
|
end
|