hermann 0.19.0 → 0.20.0

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: df28bdfb07a0ed99d0bd3b2e60bf0a40a078f359
4
- data.tar.gz: e5a9810c7e622be6d7aef9f131d7b436ded85771
3
+ metadata.gz: 27f80221a9a83df130ec4513b8ecd6e1a2fe486e
4
+ data.tar.gz: 8824cb1f44e17b02e36690f5d0ee20c943a79c57
5
5
  SHA512:
6
- metadata.gz: 734f5dd11fc62af1e8777a6a07bf135af0974f6aac12a493318b63dc7b8268c597b1927daf4410d305524b80f4c6a8a05bcf953529ddc59e72a5d08d9ad2d19f
7
- data.tar.gz: a4d0de27069f7638c61a66eba2746e0e47a544c9428efa37b737d0471a4fd04ffc1502a325a53177027c74f341994ff821379ea4ad2d79e71814de8ff35405bd
6
+ metadata.gz: 88ab44fb3a43ab3bcc97e6471ddcb015a7aa828735c3157d04402ab4458053ae390de29e866a6582931c5412c3da8b7a89d96f6bf5b36fd825afd19df9923e4e
7
+ data.tar.gz: 1d5aa2469ee0cf66963184bc63976e5d353543a7cfae85db852007a9e77227a9e8ab8ea080ece9f59392e923ca9cff5d838191b72a70b87e5c51a0130562e8d8
data/Rakefile CHANGED
@@ -11,21 +11,25 @@ Rake::ExtensionTask.new do |t|
11
11
  t.gem_spec = Gem::Specification.load('hermann.gemspec')
12
12
  end
13
13
 
14
- RSpec::Core::RakeTask.new(:spec) do |r|
15
- options = ['--tag ~type:integration']
16
-
14
+ def add_rspec_options(options)
17
15
  if RUBY_PLATFORM == 'java'
18
16
  options << '--tag ~platform:mri'
19
17
  else
20
18
  options << '--tag ~platform:java'
21
19
  end
20
+ return options
21
+ end
22
+
23
+ RSpec::Core::RakeTask.new(:spec) do |r|
24
+ options = add_rspec_options(['--tag ~type:integration'])
22
25
 
23
26
  r.rspec_opts = options.join(' ')
24
27
  end
25
28
 
26
29
  namespace :spec do
27
30
  RSpec::Core::RakeTask.new(:integration) do |r|
28
- r.rspec_opts = '--tag type:integration'
31
+ options = add_rspec_options(['--tag type:integration'])
32
+ r.rspec_opts = options.join(' ')
29
33
  end
30
34
  end
31
35
 
@@ -24,8 +24,7 @@ module Hermann
24
24
  # tickTime (as set in the server configuration) and a maximum
25
25
  # of 20 times the tickTime2 times the tick time set on server"
26
26
  #
27
- # @return [String] comma separated list of brokers
28
- #
27
+ # @return [Array] List of brokers from ZK
29
28
  # @raises [NoBrokersError] if could not discover brokers thru zookeeper
30
29
  def get_brokers(timeout=0)
31
30
  brokers = []
@@ -35,7 +34,7 @@ module Hermann
35
34
  if brokers.empty?
36
35
  raise Hermann::Errors::NoBrokersError
37
36
  end
38
- brokers.join(',')
37
+ return brokers
39
38
  end
40
39
 
41
40
  private
@@ -82,4 +81,4 @@ module Hermann
82
81
  end
83
82
  end
84
83
  end
85
- end
84
+ end
@@ -1,8 +1,7 @@
1
1
 
2
2
  module Hermann
3
3
  module Errors
4
- # Error for connectivity problems with the Kafka brokers
5
- class ConnectivityError < StandardError
4
+ class GeneralError < StandardError
6
5
  attr_reader :java_exception
7
6
 
8
7
  # Initialize a connectivity error
@@ -11,17 +10,20 @@ module Hermann
11
10
  # @param [Hash[ options
12
11
  # @option options [Java::Lang::RuntimeException] :java_exception An
13
12
  # underlying Java exception
14
- def initialize(message, options={})
13
+ def initialize(message='', options={})
15
14
  super(message)
16
15
  @java_exception = options[:java_exception]
17
16
  end
18
17
  end
19
18
 
19
+ # Error for connectivity problems with the Kafka brokers
20
+ class ConnectivityError < GeneralError; end
21
+
20
22
  # For passing incorrect config and options to kafka
21
- class ConfigurationError < StandardError; end
23
+ class ConfigurationError < GeneralError; end
22
24
 
23
25
  # cannot discover brokers from zookeeper
24
- class NoBrokersError < StandardError; end
26
+ class NoBrokersError < GeneralError; end
25
27
  end
26
28
  end
27
29
 
@@ -21,7 +21,7 @@ module Hermann
21
21
  @topic = topic
22
22
  @brokers = ThreadSafe::Array.new(brokers)
23
23
  if Hermann.jruby?
24
- @internal = Hermann::Provider::JavaProducer.new(brokers, opts)
24
+ @internal = Hermann::Provider::JavaProducer.new(brokers.join(','), opts)
25
25
  else
26
26
  @internal = Hermann::Lib::Producer.new(brokers.join(','))
27
27
  end
@@ -13,7 +13,6 @@ module Hermann
13
13
 
14
14
  #default kafka Producer options
15
15
  DEFAULTS = {
16
- 'serializer.class' => 'kafka.serializer.StringEncoder',
17
16
  'partitioner.class' => 'kafka.producer.DefaultPartitioner',
18
17
  'request.required.acks' => '1',
19
18
  'message.send.max.retries' => '0'
@@ -46,12 +45,15 @@ module Hermann
46
45
  # will be set
47
46
  def push_single(msg, topic, unused)
48
47
  Concurrent::Promise.execute {
49
- data = ProducerUtil::KeyedMessage.new(topic, msg)
48
+ data = ProducerUtil::KeyedMessage.new(topic, msg.to_java_bytes)
50
49
  begin
51
50
  @producer.send(data)
52
51
  rescue Java::KafkaCommon::FailedToSendMessageException => jexc
53
52
  raise Hermann::Errors::ConnectivityError.new(jexc.message,
54
53
  :java_exception => jexc)
54
+ rescue => e
55
+ raise Hermann::Errors::GeneralError.new(e.message,
56
+ :java_exception => e)
55
57
  end
56
58
  }
57
59
  end
@@ -60,7 +60,8 @@ module Hermann
60
60
  stream = get_stream(topic)
61
61
  it = stream.iterator
62
62
  while it.hasNext do
63
- yield it.next.message.to_s
63
+ message = it.next.message
64
+ yield String.from_java_bytes(message)
64
65
  end
65
66
  rescue Exception => e
66
67
  puts "#{self.class.name}#consume exception: #{e.class.name}"
@@ -1,3 +1,3 @@
1
1
  module Hermann
2
- VERSION = '0.19.0'
2
+ VERSION = '0.20.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hermann
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Tyler Croy
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2014-10-29 00:00:00 Z
13
+ date: 2014-10-31 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: concurrent-ruby