codeclimate-kafka 0.5.0 → 0.5.1

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: 0b27b99381c9938065fdab7f96159efec38b6e7a
4
- data.tar.gz: 88c4167a50b8c5c3cbf3d04fef305392d8d3affb
3
+ metadata.gz: 92066282ad52952c0f184b8be734a682252cba67
4
+ data.tar.gz: 176ec99b426a28babea557303bd7db2660762b03
5
5
  SHA512:
6
- metadata.gz: 48ebbe244d8ed041b034eca81dc4f4b3fd7c960300fa8a6370167a4075e79fbe1afa6ed919ec21b8011ebb3e0ddebbab07dfd0e60525eff1e491e6f9acf5ff94
7
- data.tar.gz: b78c5337244a202ee3c056fd1b727981cc7fc90289d2955315c7ec4e2ea72b888c6da126f340e9c54321b9e1d4d961ac4cf6bbb735a1854be63b3031763fcf68
6
+ metadata.gz: 1971e008cb9aa3516db9c694a86d3e3dc9746eaeecd1633baf521f2954561756880001a590ea407d0fffc9c0dd91a04a6273a3e71038e1bc67a5eedc8f1c1da9
7
+ data.tar.gz: a593ecb557bc52ddc7cd4319f58a0c9875906c606037e5ff969ecb7eed395170fc2bc87c118552a6482bfaa54690ad3d7b667e912f0cc4b68e0d5df73df8201d
@@ -37,13 +37,28 @@ module CC
37
37
 
38
38
  Kafka.logger.info("shutting down due to TERM signal")
39
39
  ensure
40
- @consumer.close
40
+ close
41
41
  end
42
42
 
43
43
  def stop
44
44
  @running = false
45
45
  end
46
46
 
47
+ def fetch
48
+ @consumer.fetch
49
+ rescue Poseidon::Errors::UnknownTopicOrPartition
50
+ Kafka.logger.debug("topic #{@offset.topic.inspect} not created yet")
51
+ []
52
+ end
53
+
54
+ def set_offset(current_offset)
55
+ @offset.set(current: current_offset)
56
+ end
57
+
58
+ def close
59
+ @consumer.close
60
+ end
61
+
47
62
  private
48
63
 
49
64
  def current_offset(offset)
@@ -51,10 +66,10 @@ module CC
51
66
  end
52
67
 
53
68
  def fetch_messages
54
- @consumer.fetch.each do |message|
69
+ fetch.each do |message|
55
70
  Kafka.statsd.increment("messages.received")
56
71
  Kafka.statsd.time("messages.processing") do
57
- @offset.set(current: message.offset + 1)
72
+ set_offset(message.offset + 1)
58
73
 
59
74
  Kafka.offset_model.transaction do
60
75
  data = BSON.deserialize(message.value)
@@ -69,10 +84,6 @@ module CC
69
84
  end
70
85
  Kafka.statsd.increment("messages.processed")
71
86
  end
72
- rescue Poseidon::Errors::UnknownTopicOrPartition
73
- Kafka.logger.debug("topic #{@topic} not created yet")
74
-
75
- sleep 1
76
87
  end
77
88
  end
78
89
  end
@@ -1,5 +1,5 @@
1
1
  module CC
2
2
  module Kafka
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Climate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson