codeclimate-poseidon 0.0.11 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577a257d21ed35cf7b09178cb0a5a81ecc6db334
4
- data.tar.gz: 5d0544002eeb23d1d167b87973916245921c4616
3
+ metadata.gz: aa02e321bdedaf1f2ab107fa19baa839f8b8975e
4
+ data.tar.gz: 6be2d71921b325c65013edaa05f4be605f67bf61
5
5
  SHA512:
6
- metadata.gz: 89825b99bc8aee674c6eea0933708b9e0b4f0ac723b27e9e3a9af664afd7a502b2cae228f5930ce88049d2ad1f9e69e06cd94f494f7fd328a747416b73b04f67
7
- data.tar.gz: 3b25ee0806f6fb045d2207f6d208a5d5c6fee05c16b603a0d3b65d609b66bb66ef642e57878b23bc080647909154e4668e38fd2cc8dd2a1056e2514efde03ba4
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
@@ -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 Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, TimeoutException => ex
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
@@ -1,4 +1,4 @@
1
1
  module Poseidon
2
2
  # Unstable! API May Change!
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Producer do
4
4
  it "requires brokers and client_id" do
5
- expect { Producer.new }.to raise_error
5
+ expect { Producer.new }.to raise_error(ArgumentError)
6
6
  end
7
7
 
8
8
  it "raises ArgumentError on unknown arguments" do
@@ -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
@@ -95,7 +95,7 @@ RSpec.describe SyncProducer do
95
95
  it "raises an exception" do
96
96
  expect {
97
97
  @sp.send_messages([Message.new(:topic => "topic", :value => "value")])
98
- }.to raise_error
98
+ }.to raise_error(Poseidon::Errors::MessageDeliveryError)
99
99
  end
100
100
  end
101
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-poseidon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Potter