codeclimate-poseidon 0.0.9 → 0.0.10

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: 24d819569b92bc26b634a8914fe26cb06f20ffb7
4
- data.tar.gz: 32f521faf32658fe3bef867e68680c566039e97b
3
+ metadata.gz: 13660b540273d883d04fc215d955661f274e19d2
4
+ data.tar.gz: d42aac80cd5a5da6ca54eb68117c936c3b845c96
5
5
  SHA512:
6
- metadata.gz: c2a37c2ac0b556382a0cdfa5db90c18a2e95b81f6d7a3e386b30fb8fa1bbd660d985daffced2072c0f913ac243df77824d2cdbbd5aeb90a1bde03e966d286c0e
7
- data.tar.gz: d03477476c96df18826b9c9406ce7585242e5893673a7be35661a4ac82736c797d318e2579875f09fe3a17f692a04a346b3f5e9230ad22e81c736a1c865e02e4
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
@@ -0,0 +1,7 @@
1
+ .PHONY: image test
2
+
3
+ image:
4
+ docker build -t codeclimate/codeclimate-poseidon .
5
+
6
+ test: image
7
+ docker run --rm -t codeclimate/codeclimate-poseidon bundle exec rake spec:all
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ machine:
2
+ services:
3
+ - docker
4
+
5
+ dependencies:
6
+ override:
7
+ - make image
8
+
9
+ test:
10
+ override:
11
+ - make test
@@ -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
- raise_connection_failed_error
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
- raise_connection_failed_error
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
- raise_connection_failed_error
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 raise_connection_failed_error
166
- raise ConnectionFailedError, "Failed to connect to #{@host}:#{@port}"
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
@@ -1,4 +1,4 @@
1
1
  module Poseidon
2
2
  # Unstable! API May Change!
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
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.9
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-25 00:00:00.000000000 Z
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