codeclimate-poseidon 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +21 -0
- data/Makefile +7 -0
- data/circle.yml +11 -0
- data/lib/poseidon/connection.rb +15 -11
- data/lib/poseidon/sync_producer.rb +2 -2
- data/lib/poseidon/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13660b540273d883d04fc215d955661f274e19d2
|
4
|
+
data.tar.gz: d42aac80cd5a5da6ca54eb68117c936c3b845c96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711f1fa68fd8a26e47a42fb259b1296ccd01e02ed4137d26d9fc279158fe60b50fc94a6d4a73ff5118114674265dabf687e9f08fe224d655f73212096df2e108
|
7
|
+
data.tar.gz: 54c58a0f9fe5650dac5e498b246df497032336e347307f94b2c7aa2181af31276d6b537e14681df6f0dfb8df122bae7ccfc5f1411029f31cdb7b0607d8392bcc
|
data/Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
FROM ruby:2.3.1-alpine
|
2
|
+
MAINTAINER Code Climate <hello@codeclimate.com>
|
3
|
+
|
4
|
+
RUN apk --update add git build-base autoconf automake libtool ruby-dev ruby-bundler snappy openjdk8 && \
|
5
|
+
rm -fr /usr/share/ri
|
6
|
+
|
7
|
+
ENV KAFKA_SRC=http://apache.cs.utah.edu/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz
|
8
|
+
ENV KAFKA_PATH=/usr/src/kafka
|
9
|
+
|
10
|
+
RUN curl "$KAFKA_SRC" | tar xvzf - && mv kafka_* "$KAFKA_PATH"
|
11
|
+
|
12
|
+
WORKDIR /usr/src/poseidon/
|
13
|
+
|
14
|
+
COPY .git/ /usr/src/poseidon/
|
15
|
+
COPY Gemfile* /usr/src/poseidon/
|
16
|
+
COPY poseidon.gemspec /usr/src/poseidon/
|
17
|
+
COPY lib/poseidon/version.rb /usr/src/poseidon/lib/poseidon/
|
18
|
+
|
19
|
+
RUN bundle install -j 4
|
20
|
+
|
21
|
+
COPY . /usr/src/poseidon/
|
data/Makefile
ADDED
data/circle.yml
ADDED
data/lib/poseidon/connection.rb
CHANGED
@@ -51,7 +51,7 @@ module Poseidon
|
|
51
51
|
req = ProduceRequest.new( request_common(:produce),
|
52
52
|
required_acks,
|
53
53
|
timeout,
|
54
|
-
messages_for_topics)
|
54
|
+
messages_for_topics)
|
55
55
|
send_request(req)
|
56
56
|
if required_acks != 0
|
57
57
|
read_response(ProduceResponse)
|
@@ -71,7 +71,7 @@ module Poseidon
|
|
71
71
|
REPLICA_ID,
|
72
72
|
max_wait_time,
|
73
73
|
min_bytes,
|
74
|
-
topic_fetches)
|
74
|
+
topic_fetches)
|
75
75
|
send_request(req)
|
76
76
|
read_response(FetchResponse)
|
77
77
|
end
|
@@ -103,8 +103,8 @@ module Poseidon
|
|
103
103
|
if @socket.nil? || @socket.closed?
|
104
104
|
begin
|
105
105
|
@socket = TCPSocket.new(@host, @port)
|
106
|
-
rescue SystemCallError
|
107
|
-
|
106
|
+
rescue SystemCallError => ex
|
107
|
+
raise_connection_failed_from_exception(ex)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -112,15 +112,15 @@ module Poseidon
|
|
112
112
|
def read_response(response_class)
|
113
113
|
r = ensure_read_or_timeout(4)
|
114
114
|
if r.nil?
|
115
|
-
raise_connection_failed_error
|
115
|
+
raise_connection_failed_error("Could not read from socket")
|
116
116
|
end
|
117
117
|
n = r.unpack("N").first
|
118
118
|
s = ensure_read_or_timeout(n)
|
119
119
|
buffer = Protocol::ResponseBuffer.new(s)
|
120
120
|
response_class.read(buffer)
|
121
|
-
rescue Errno::ECONNRESET, SocketError, TimeoutException
|
121
|
+
rescue Errno::ECONNRESET, SocketError, TimeoutException => ex
|
122
122
|
@socket = nil
|
123
|
-
|
123
|
+
raise_connection_failed_from_exception(ex)
|
124
124
|
end
|
125
125
|
|
126
126
|
def ensure_read_or_timeout(maxlen)
|
@@ -135,9 +135,9 @@ module Poseidon
|
|
135
135
|
buffer = Protocol::RequestBuffer.new
|
136
136
|
request.write(buffer)
|
137
137
|
ensure_write_or_timeout([buffer.to_s.bytesize].pack("N") + buffer.to_s)
|
138
|
-
rescue Errno::EPIPE, Errno::ECONNRESET, TimeoutException
|
138
|
+
rescue Errno::EPIPE, Errno::ECONNRESET, TimeoutException => ex
|
139
139
|
@socket = nil
|
140
|
-
|
140
|
+
raise_connection_failed_from_exception(ex)
|
141
141
|
end
|
142
142
|
|
143
143
|
def ensure_write_or_timeout(data)
|
@@ -162,8 +162,12 @@ module Poseidon
|
|
162
162
|
@correlation_id += 1
|
163
163
|
end
|
164
164
|
|
165
|
-
def
|
166
|
-
|
165
|
+
def raise_connection_failed_from_exception(ex)
|
166
|
+
raise_connection_failed_error("Initial exception class=#{ex.class} message=#{ex.message}")
|
167
|
+
end
|
168
|
+
|
169
|
+
def raise_connection_failed_error(message)
|
170
|
+
raise ConnectionFailedError, "Failed to connect to #{@host}:#{@port}. #{message}"
|
167
171
|
end
|
168
172
|
end
|
169
173
|
end
|
@@ -155,8 +155,8 @@ module Poseidon
|
|
155
155
|
else
|
156
156
|
messages_for_broker.successfully_sent(response)
|
157
157
|
end
|
158
|
-
rescue Connection::ConnectionFailedError
|
159
|
-
Poseidon.logger.warn { "Failed to send messages to #{messages_for_broker.broker_id} due to connection failure"
|
158
|
+
rescue Connection::ConnectionFailedError => ex
|
159
|
+
Poseidon.logger.warn { "Failed to send messages to #{messages_for_broker.broker_id} due to connection failure: message=#{ex.message}" }
|
160
160
|
false
|
161
161
|
end
|
162
162
|
end
|
data/lib/poseidon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate-poseidon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Potter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -92,11 +92,14 @@ files:
|
|
92
92
|
- ".travis.yml"
|
93
93
|
- ".yardopts"
|
94
94
|
- CHANGES.md
|
95
|
+
- Dockerfile
|
95
96
|
- Gemfile
|
96
97
|
- LICENSE.txt
|
98
|
+
- Makefile
|
97
99
|
- README.md
|
98
100
|
- Rakefile
|
99
101
|
- TODO.md
|
102
|
+
- circle.yml
|
100
103
|
- examples/consumer.rb
|
101
104
|
- examples/producer.rb
|
102
105
|
- lib/poseidon.rb
|