heller 0.0.1-java → 0.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,11 +42,17 @@ module Heller
42
42
  end
43
43
 
44
44
  def parse_multi_fetch_response(topics, response)
45
- response_array = topics.zip(response.to_a)
46
-
47
- response_array.inject({}) do |response_hash, (topic, messages)|
48
- response_hash[topic] = messages.to_a
49
- response_hash
45
+ if response.respond_to?(:to_a)
46
+ response_array = topics.zip(response.to_a)
47
+
48
+ response_array.inject({}) do |response_hash, (topic, messages)|
49
+ response_hash[topic] = messages.to_a
50
+ response_hash
51
+ end
52
+ else
53
+ puts 'response does not respond to #to_a'
54
+ puts "response is #{response.inspect}"
55
+ puts "topics were: #{topics.inspect}"
50
56
  end
51
57
  end
52
58
  end
@@ -1,36 +1,23 @@
1
1
  module Heller
2
- class Producer < Kafka::Producer::SyncProducer
2
+ class Producer < Kafka::Producer::Producer
3
3
 
4
4
  attr_reader :configuration
5
5
 
6
- def initialize(host, port, options = {})
6
+ def initialize(zk_connect, options = {})
7
7
  options.merge!({
8
- 'host' => host,
9
- 'port' => port.to_s
8
+ 'zk.connect' => zk_connect
10
9
  })
11
10
 
12
- @configuration = Kafka::Producer::SyncProducerConfig.new(hash_to_properties(options))
13
-
14
- super(@configuration)
11
+ @configuration = Kafka::Producer::ProducerConfig.new(hash_to_properties(options))
12
+ super @configuration
15
13
  end
16
14
 
17
- def wrap_messages(messages)
18
- converted = messages.map do |m|
19
- Kafka::Message::Message.new(m)
15
+ def produce(topic_mappings)
16
+ producer_data = topic_mappings.map do |topic, messages|
17
+ Kafka::Producer::ProducerData.new(topic, messages)
20
18
  end
21
19
 
22
- Kafka::Message::ByteBufferMessageSet.new(ArrayList.new(converted))
23
- end
24
-
25
- def produce(topic, messages, partition = :random)
26
- message_set = wrap_messages(messages)
27
-
28
- case partition
29
- when :random
30
- send(topic, message_set)
31
- when Integer
32
- send(topic, partition, message_set)
33
- end
20
+ send(producer_data)
34
21
  end
35
22
 
36
23
  protected
data/lib/kafka.rb CHANGED
@@ -21,7 +21,12 @@ module Kafka
21
21
  end
22
22
 
23
23
  module Producer
24
+ java_import 'kafka.producer.ProducerConfig'
24
25
  java_import 'kafka.producer.SyncProducerConfig'
26
+
27
+ java_import 'kafka.javaapi.producer.ProducerData'
28
+
25
29
  java_import 'kafka.javaapi.producer.SyncProducer'
30
+ java_import 'kafka.javaapi.producer.Producer'
26
31
  end
27
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: java
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kafka-jars
@@ -17,13 +17,13 @@ dependencies:
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 0.7.2.1
20
+ version: 0.7.2.2
21
21
  none: false
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.7.2.1
26
+ version: 0.7.2.2
27
27
  none: false
28
28
  prerelease: false
29
29
  type: :runtime
@@ -34,14 +34,10 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - !binary |-
38
- bGliL2hlbGxlci5yYg==
39
- - !binary |-
40
- bGliL2thZmthLnJi
41
- - !binary |-
42
- bGliL2hlbGxlci9jb25zdW1lci5yYg==
43
- - !binary |-
44
- bGliL2hlbGxlci9wcm9kdWNlci5yYg==
37
+ - lib/heller.rb
38
+ - lib/kafka.rb
39
+ - lib/heller/consumer.rb
40
+ - lib/heller/producer.rb
45
41
  homepage: http://github.com/mthssdrbrg/heller
46
42
  licenses: []
47
43
  post_install_message:
@@ -52,15 +48,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
48
  requirements:
53
49
  - - ! '>='
54
50
  - !ruby/object:Gem::Version
55
- version: !binary |-
56
- MA==
51
+ version: '0'
57
52
  none: false
58
53
  required_rubygems_version: !ruby/object:Gem::Requirement
59
54
  requirements:
60
55
  - - ! '>='
61
56
  - !ruby/object:Gem::Version
62
- version: !binary |-
63
- MA==
57
+ version: '0'
64
58
  none: false
65
59
  requirements: []
66
60
  rubyforge_project: heller
@@ -69,3 +63,5 @@ signing_key:
69
63
  specification_version: 3
70
64
  summary: JRuby wrapper for Kafka
71
65
  test_files: []
66
+ has_rdoc:
67
+ ...