codeclimate-kafka 0.4.0 → 0.5.0
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 +4 -4
- data/lib/cc/kafka/consumer.rb +6 -2
- data/lib/cc/kafka/offset_storage/memory.rb +19 -0
- data/lib/cc/kafka/offset_storage/minidoc.rb +24 -0
- data/lib/cc/kafka/version.rb +1 -1
- data/lib/cc/kafka.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b27b99381c9938065fdab7f96159efec38b6e7a
|
4
|
+
data.tar.gz: 88c4167a50b8c5c3cbf3d04fef305392d8d3affb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ebbe244d8ed041b034eca81dc4f4b3fd7c960300fa8a6370167a4075e79fbe1afa6ed919ec21b8011ebb3e0ddebbab07dfd0e60525eff1e491e6f9acf5ff94
|
7
|
+
data.tar.gz: b78c5337244a202ee3c056fd1b727981cc7fc90289d2955315c7ec4e2ea72b888c6da126f340e9c54321b9e1d4d961ac4cf6bbb735a1854be63b3031763fcf68
|
data/lib/cc/kafka/consumer.rb
CHANGED
@@ -11,14 +11,14 @@ module CC
|
|
11
11
|
partition: partition,
|
12
12
|
)
|
13
13
|
|
14
|
-
Kafka.logger.debug("offset: #{@offset.topic}/#{@offset.partition} #{@offset
|
14
|
+
Kafka.logger.debug("offset: #{@offset.topic}/#{@offset.partition} #{current_offset(@offset)}")
|
15
15
|
|
16
16
|
@consumer = Poseidon::PartitionConsumer.consumer_for_partition(
|
17
17
|
client_id,
|
18
18
|
seed_brokers,
|
19
19
|
@offset.topic,
|
20
20
|
@offset.partition,
|
21
|
-
@offset
|
21
|
+
current_offset(@offset)
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
@@ -46,6 +46,10 @@ module CC
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
+
def current_offset(offset)
|
50
|
+
offset.current || :earliest_offset
|
51
|
+
end
|
52
|
+
|
49
53
|
def fetch_messages
|
50
54
|
@consumer.fetch.each do |message|
|
51
55
|
Kafka.statsd.increment("messages.received")
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CC
|
2
|
+
module Kafka
|
3
|
+
module OffsetStorage
|
4
|
+
Memory = Struct.new(:topic, :partition, :current) do
|
5
|
+
def self.transaction
|
6
|
+
yield
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find_or_create!(attrs)
|
10
|
+
@offset ||= new(attrs[:topic], attrs[:partition], nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def set(attrs)
|
14
|
+
attrs.each { |k, v| self[k] = v }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CC
|
2
|
+
module Kafka
|
3
|
+
module OffsetStorage
|
4
|
+
module Minidoc
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
base.include ::Minidoc::Indexes
|
8
|
+
|
9
|
+
base.attribute :topic, String
|
10
|
+
base.attribute :partition, Integer
|
11
|
+
base.attribute :current, Integer
|
12
|
+
|
13
|
+
base.ensure_index [:partition, :topic], unique: true
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def find_or_create!(attributes)
|
18
|
+
find_one(attributes) || create!(attributes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cc/kafka/version.rb
CHANGED
data/lib/cc/kafka.rb
CHANGED
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.
|
4
|
+
version: 0.5.0
|
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-
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson
|
@@ -74,6 +74,8 @@ extra_rdoc_files: []
|
|
74
74
|
files:
|
75
75
|
- lib/cc/kafka.rb
|
76
76
|
- lib/cc/kafka/consumer.rb
|
77
|
+
- lib/cc/kafka/offset_storage/memory.rb
|
78
|
+
- lib/cc/kafka/offset_storage/minidoc.rb
|
77
79
|
- lib/cc/kafka/producer.rb
|
78
80
|
- lib/cc/kafka/producer/http.rb
|
79
81
|
- lib/cc/kafka/producer/poseidon.rb
|