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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a9e9d18567496651c7c390954320166410d315f
4
- data.tar.gz: a17c4b5192bcd360bd7fe2eda5da3b6d9afcf0a9
3
+ metadata.gz: 58d3c657309fe7381c8776baa87f54b41f04281f
4
+ data.tar.gz: 009a15759814e1c92bdec7e903d9a8fb16a4ce4a
5
5
  SHA512:
6
- metadata.gz: c241fca61a6a6c6b59b32d023250665c939fb3f4c34cdddd4bb9cfbb125a4bab8bc87f405e0e496e2a14e6a8d9d6c6ef9278d85d369ddcde30afbad844fd0536
7
- data.tar.gz: 170438cf674768bfc7f4002332f16f1d89d9a0669278e6f801d1dc10e6e0bfd1a9093fcd382bf3ba9adb88491bf11ba348d36e84e803e5a3bb0c2f80079cee2e
6
+ metadata.gz: 1fc88b0a4b8f27cb3314db151956242a1c1e3caaa78fa89a17c15907e28a0cfc6ac0bfeadd26829245a01e331ee1112bf6abf2201357418f5bccef4b0ddb933c
7
+ data.tar.gz: 79d9a39b2ab8a424ed3e0d44419e3c021983afb617637db237ce2ee0134ff18dcaca7494ce65bd535b400cfb1ef816cacf20d0a8c7ebe1c32bd1b05356a699c9
@@ -6,3 +6,4 @@ rvm:
6
6
  - jruby-19mode
7
7
  env:
8
8
  - SLOW=1
9
+ script: bundle exec rake spec:coveralls
data/Gemfile CHANGED
@@ -2,7 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
  gem "poseidon", git: "https://github.com/dim/poseidon.git"
5
- gem "coveralls", require: false
6
5
 
7
6
  platform :jruby do
8
7
  gem 'slyphon-log4j', '= 1.2.15'
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- poseidon_cluster (0.0.3)
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.0)
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
@@ -7,4 +7,10 @@ require 'yard'
7
7
  require 'yard/rake/yardoc_task'
8
8
  YARD::Rake::YardocTask.new
9
9
 
10
+ require 'coveralls/rake/task'
11
+ Coveralls::RakeTask.new
12
+ namespace :spec do
13
+ task coveralls: [:spec, 'coveralls:push']
14
+ end
15
+
10
16
  task default: :spec
@@ -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 = name
76
- @topic = topic
77
- @zk = ::ZK.new(zookeepers.join(","))
78
- @options = options
79
- @consumers = []
80
- @pool = ::Poseidon::BrokerPool.new(id, brokers)
81
- @mutex = Mutex.new
82
-
83
- # Register instance
84
- registries.each do |_, path|
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
@@ -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.3"
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
- 8.times do
145
+ 10.times do
145
146
  50.times { group.fetch {|_, m| write.write "5:#{m.size}\n" }}
146
- sleep(2)
147
+ sleep(3)
147
148
  end
148
149
  end
149
150
  Process.wait(pid1)
@@ -50,6 +50,7 @@ describe Poseidon::ConsumerGroup do
50
50
  groups.each(&:close)
51
51
  end
52
52
 
53
+ it { should be_registered }
53
54
  its(:name) { should == "my-group" }
54
55
  its(:topic) { should == TOPIC_NAME }
55
56
  its(:pool) { should be_instance_of(Poseidon::BrokerPool) }
@@ -3,7 +3,6 @@ require 'rspec'
3
3
  require 'fileutils'
4
4
  require 'pathname'
5
5
  require 'coveralls'
6
- Coveralls.wear!
7
6
 
8
7
  TOPIC_NAME = "my-topic"
9
8
  KAFKA_LOCAL = File.expand_path("../kafka_2.8.0-0.8.0", __FILE__)
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.3
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-18 00:00:00.000000000 Z
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.0.rc.1
153
+ rubygems_version: 2.2.1
140
154
  signing_key:
141
155
  specification_version: 4
142
156
  summary: Poseidon cluster extensions