Merge remote-tracking branch 'upstream/master' into cleanup_warnings

This commit is contained in:
Ben Osheroff 2015-06-16 23:42:09 -07:00
commit e7fce39f83
10 changed files with 44 additions and 17 deletions

View File

@ -4,6 +4,7 @@ rvm:
- 2.1
- 1.9.3
- jruby
- ree
deploy:
provider: rubygems
gemspec: hermann.gemspec

View File

@ -5,6 +5,8 @@ gemspec
group :development do
gem 'jbundler', :platform => :jruby
gem 'rake'
gem 'i18n', '~> 0.6.11', :platform => :mri_18
gem 'activesupport', '~> 3.x', :platform => :mri_18
gem 'ruby-maven', '~> 3.1.1.0', :platform => :jruby
gem 'jar-dependencies', :platform => :jruby
gem 'rake-compiler'

View File

@ -8,5 +8,23 @@
* set port 2181
* Start Kafka
* Set properties file ```zookeeper.connect=localhost:2181```
You can also use a docker instance like this one : https://github.com/spotify/docker-kafka
On mac :
* ```boot2docker start ```
* ```$(boot2docker shellinit)```
* ```docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=`boot2docker ip` --env ADVERTISED_PORT=9092 spotify/kafka```
* ```export ZOOKEEPER=`boot2docker ip`:2181```
* ```export KAFKA=`boot2docker ip`:9092 ```
* modify ./fixtures/integration.yml with values in $KAKFA and $ZOOKEEPER
#### With JRuby
* ```bundle exec jruby -S rspec spec/integration```
#### With MRI
* ```bundle install```
* ```rake default``` or ```rake compile``` and then ```rake spec```
* ```rake spec:intregration```

View File

@ -26,7 +26,7 @@ straightforward.
### Producer
#### Zookeeper discovery (JRuby-only)
#### Zookeeper discovery
Discover Kafka brokers through zookeeper. Looks at ```/brokers/ids``` in Zookeeper to find the list of brokers.
@ -48,10 +48,11 @@ promise.state # the state of the promise
```ruby
require 'hermann/producer'
p = Hermann::Producer.new('topic', ['localhost:6667']) # arguments topic, list of brokers
f = p.push('hello world from mri')
f.state
p.tick_reactor
broker_ids_array = Hermann::Discovery::Zookeeper.new('localhost:2181').get_brokers
p = Hermann::Producer.new('topic', broker_ids_array) # arguments topic, list of brokers
f = p.push('hello world from mri')
f.state
p.tick_reactor
f.state
```
@ -94,9 +95,11 @@ the_consumer.consume(new_topic) do |msg| # can change topic with optional argu
end
```
#### Testing
To run the integration tests:
* startup your own instance of zookeeper/kafka
* `rspec spec/integration/producer_spec.rb`
#### How to convert from using jruby-kafka

View File

@ -24,10 +24,12 @@ Gem::Specification.new do |s|
s.rubygems_version = '2.2.2'
s.specification_version = 3 if s.respond_to?(:specification_version)
s.add_dependency 'concurrent-ruby', '~> 0.7.0'
s.add_dependency 'json', '~> 1.8.2'
s.add_dependency 'thread_safe', '~> 0.3.4'
if RUBY_PLATFORM == "java"
s.add_dependency 'concurrent-ruby', '~> 0.7.0'
# IMPORTANT: make sure that jar-dependencies is only a development
# dependency of your gem. if it is a runtime dependencies the require_jars
# file will be overwritten during installation.

View File

@ -1,6 +1,7 @@
module Hermann
require 'java'
require 'hermann_jars'
require 'concurrent'
module JavaUtil
include_package 'java.util'

View File

@ -1,6 +1,5 @@
require 'hermann'
require 'concurrent'
require 'json'
require 'hermann'
require 'hermann/errors'
module Hermann

View File

@ -55,7 +55,7 @@ describe Hermann::Consumer do
end
context 'on Jruby', :platform => :java do
subject(:consumer) { described_class.new(topic, group_id: groupId, zookeepers: zookeepers) }
subject(:consumer) { described_class.new(topic, :group_id => groupId, :zookeepers => zookeepers) }
let(:zookeepers) { 'localhost:2181' }
let(:groupId) { 'groupId' }

View File

@ -3,18 +3,19 @@ require 'spec_helper'
require 'hermann/producer'
require 'hermann/consumer'
require 'hermann/discovery/zookeeper'
require 'concurrent'
require 'protobuf'
require_relative '../fixtures/testevent.pb'
describe 'producer' do
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../'))
require 'fixtures/testevent.pb'
describe 'producer', :platform => :java do
include_context 'integration test context'
let(:timeout) { 10 }
let(:message) { 'msg' }
let(:consumer) do
Hermann::Consumer.new(topic, "rspec-group", zookeepers)
Hermann::Consumer.new(topic, { :group_id => "rspec-group", :zookeepers => zookeepers })
end
let(:consumer_promise) do
Concurrent::Promise.execute do

View File

@ -13,8 +13,8 @@ RSpec.configure do |c|
c.formatter = :documentation
shared_context 'integration test context', :type => :integration do
let(:topic) { "hermann_testing_" + rand(100_000_000).to_s }
let(:brokers) { $integrationconf['kafka']['brokers'] }
let(:topic) { "hermann_testing" }
let(:brokers) { $integrationconf['kafka']['brokers'].join(',') }
let(:zookeepers) { $integrationconf['zookeepers'] }
end
end