poseidon_cluster 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/Rakefile +6 -0
- data/lib/poseidon/consumer_group.rb +32 -17
- data/poseidon_cluster.gemspec +2 -1
- data/spec/integration/poseidon/consumer_group_spec.rb +3 -2
- data/spec/lib/poseidon/consumer_group_spec.rb +1 -0
- data/spec/spec_helper.rb +0 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d3c657309fe7381c8776baa87f54b41f04281f
|
4
|
+
data.tar.gz: 009a15759814e1c92bdec7e903d9a8fb16a4ce4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc88b0a4b8f27cb3314db151956242a1c1e3caaa78fa89a17c15907e28a0cfc6ac0bfeadd26829245a01e331ee1112bf6abf2201357418f5bccef4b0ddb933c
|
7
|
+
data.tar.gz: 79d9a39b2ab8a424ed3e0d44419e3c021983afb617637db237ce2ee0134ff18dcaca7494ce65bd535b400cfb1ef816cacf20d0a8c7ebe1c32bd1b05356a699c9
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ GIT
|
|
7
7
|
PATH
|
8
8
|
remote: .
|
9
9
|
specs:
|
10
|
-
poseidon_cluster (0.0.
|
10
|
+
poseidon_cluster (0.0.5)
|
11
11
|
poseidon
|
12
12
|
zk
|
13
13
|
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
little-plugger (1.1.3)
|
26
26
|
logging (1.7.2)
|
27
27
|
little-plugger (>= 1.1.3)
|
28
|
-
mime-types (2.
|
28
|
+
mime-types (2.1)
|
29
29
|
multi_json (1.8.4)
|
30
30
|
rake (10.1.1)
|
31
31
|
rest-client (1.6.7)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Poseidon Cluster [![Build Status](https://travis-ci.org/bsm/poseidon_cluster.png?branch=master)](https://travis-ci.org/bsm/poseidon_cluster)
|
1
|
+
# Poseidon Cluster [![Build Status](https://travis-ci.org/bsm/poseidon_cluster.png?branch=master)](https://travis-ci.org/bsm/poseidon_cluster) [![Coverage Status](https://coveralls.io/repos/bsm/poseidon_cluster/badge.png)](https://coveralls.io/r/bsm/poseidon_cluster)
|
2
2
|
|
3
3
|
Poseidon Cluster is a cluster extension the excellent [Poseidon](http://github.com/bpot/poseidon) Ruby client for Kafka 0.8+. It implements the distribution concept of self-rebalancing *Consumer Groups* and supports the consumption of a single topic from multiple instances.
|
4
4
|
|
data/Rakefile
CHANGED
@@ -69,26 +69,20 @@ class Poseidon::ConsumerGroup
|
|
69
69
|
# @option options [Integer] :min_bytes Smallest amount of data the server should send us. Default: 0 (Send us data as soon as it is ready)
|
70
70
|
# @option options [Integer] :claim_timeout Maximum number of seconds to wait for a partition claim. Default: 10
|
71
71
|
# @option options [Integer] :loop_delay Number of seconds to delay the next fetch (in #fetch_loop) if nothing was returned. Default: 1
|
72
|
+
# @option options [Boolean] :register Automatically register instance and start consuming. Default: true
|
72
73
|
#
|
73
74
|
# @api public
|
74
75
|
def initialize(name, brokers, zookeepers, topic, options = {})
|
75
|
-
@name
|
76
|
-
@topic
|
77
|
-
@zk
|
78
|
-
@options
|
79
|
-
@consumers
|
80
|
-
@pool
|
81
|
-
@mutex
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
zk.mkdir_p(path)
|
86
|
-
end
|
87
|
-
zk.create(consumer_path, "{}", ephemeral: true)
|
88
|
-
zk.register(registries[:consumer]) {|_| rebalance! }
|
89
|
-
|
90
|
-
# Rebalance
|
91
|
-
rebalance!
|
76
|
+
@name = name
|
77
|
+
@topic = topic
|
78
|
+
@zk = ::ZK.new(zookeepers.join(","))
|
79
|
+
@options = options
|
80
|
+
@consumers = []
|
81
|
+
@pool = ::Poseidon::BrokerPool.new(id, brokers)
|
82
|
+
@mutex = Mutex.new
|
83
|
+
@registered = false
|
84
|
+
|
85
|
+
register! unless options[:register] == false
|
92
86
|
end
|
93
87
|
|
94
88
|
# @return [String] a globally unique identifier
|
@@ -115,6 +109,27 @@ class Poseidon::ConsumerGroup
|
|
115
109
|
@topic_metadata ||= metadata.metadata_for_topics([topic])[topic]
|
116
110
|
end
|
117
111
|
|
112
|
+
# @return [Boolean] true if registered
|
113
|
+
def registered?
|
114
|
+
@registered
|
115
|
+
end
|
116
|
+
|
117
|
+
# @return [Boolean] true if registration was successful, false if already registered
|
118
|
+
def register!
|
119
|
+
return false if registered?
|
120
|
+
|
121
|
+
# Register instance
|
122
|
+
registries.each do |_, path|
|
123
|
+
zk.mkdir_p(path)
|
124
|
+
end
|
125
|
+
zk.create(consumer_path, "{}", ephemeral: true)
|
126
|
+
zk.register(registries[:consumer]) {|_| rebalance! }
|
127
|
+
|
128
|
+
# Rebalance
|
129
|
+
rebalance!
|
130
|
+
@registered = true
|
131
|
+
end
|
132
|
+
|
118
133
|
# Reloads metadata/broker/partition information
|
119
134
|
def reload
|
120
135
|
@metadata = @topic_metadata = nil
|
data/poseidon_cluster.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = File.basename(__FILE__, '.gemspec')
|
6
6
|
s.summary = "Poseidon cluster extensions"
|
7
7
|
s.description = "Cluster extensions for Poseidon, a producer and consumer implementation for Kafka >= 0.8"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.authors = ["Black Square Media"]
|
11
11
|
s.email = "info@blacksquaremedia.com"
|
@@ -22,5 +22,6 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency "bundler"
|
23
23
|
s.add_development_dependency "rspec"
|
24
24
|
s.add_development_dependency "yard"
|
25
|
+
s.add_development_dependency "coveralls"
|
25
26
|
|
26
27
|
end
|
@@ -139,11 +139,12 @@ describe Poseidon::ConsumerGroup, integration: true do
|
|
139
139
|
50.times { group.fetch {|_, m| write.write "4:#{m.size}\n" }}
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
142
143
|
pid5 = fork do
|
143
144
|
group = new_group(32*1024, "slow-topic")
|
144
|
-
|
145
|
+
10.times do
|
145
146
|
50.times { group.fetch {|_, m| write.write "5:#{m.size}\n" }}
|
146
|
-
sleep(
|
147
|
+
sleep(3)
|
147
148
|
end
|
148
149
|
end
|
149
150
|
Process.wait(pid1)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poseidon_cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Black Square Media
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: poseidon
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Cluster extensions for Poseidon, a producer and consumer implementation
|
98
112
|
for Kafka >= 0.8
|
99
113
|
email: info@blacksquaremedia.com
|
@@ -136,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
150
|
version: 1.8.0
|
137
151
|
requirements: []
|
138
152
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.2.
|
153
|
+
rubygems_version: 2.2.1
|
140
154
|
signing_key:
|
141
155
|
specification_version: 4
|
142
156
|
summary: Poseidon cluster extensions
|