jruby-kafka 3.1-java → 3.2-java

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: 9c40aa86664e77cc7c8d72fc64faf35ae7e0faf4
4
- data.tar.gz: 10d8d7885ef6cceaa4909c35effd266c32dbea61
3
+ metadata.gz: 5d8bd0569f81f64429f450dfc7fb1ba4535da82b
4
+ data.tar.gz: 5bacffc343af3b196e2841f49b68cd8c1c6e80dc
5
5
  SHA512:
6
- metadata.gz: af9955f296c47e9f9b78cd0a48bc4cff1c7b286a23900e64ed9eaf4f3b21b37de8ccb4a3dceb08cf6400a7f90a1c934594b9e8711a1f197c7f8c9986a6c1f873
7
- data.tar.gz: 660691b2f5efda694e349ecb723ee995d386d801dc0fd9fdcf00c8bec3221b14aba2f5cb6a47fb4b865766283fbda1b6805425b411f3f99c3edee3d498a99c63
6
+ metadata.gz: da3dcfb455b352a7ac92ab2fcc77be7c69a7d675a34c1ebf7ad30c48a2fc356e492478c4d2d34f3b1502149b2fe0d9dfba60eb10a14401386568a40ff68a595d
7
+ data.tar.gz: 279da18f0d1cedb2db4e04956ee585a21302894330149d531e6ab5c42a924cec145f852aa54ea2e5284a7c2a3d4e3d21ffddb190ea3832b06aa905dc1d4b3acb
data/lib/jruby-kafka.rb CHANGED
@@ -3,3 +3,4 @@ require 'jruby-kafka_jars.rb'
3
3
  require 'jruby-kafka/consumer'
4
4
  require 'jruby-kafka/producer'
5
5
  require 'jruby-kafka/kafka-producer'
6
+ require 'jruby-kafka/kafka-consumer'
@@ -0,0 +1,77 @@
1
+ require 'java'
2
+ require 'jruby-kafka/namespace'
3
+ require "concurrent"
4
+
5
+ class Kafka::KafkaConsumer
6
+ KAFKA_CONSUMER = Java::org.apache.kafka.clients.consumer.KafkaConsumer
7
+ # Create a Kafka high-level consumer.
8
+ #
9
+ # @param [Hash] config the consumer configuration.
10
+ #
11
+ # @option config [String] :bootstrap_servers A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. The client will make use of all servers irrespective of which servers are specified here for bootstrapping—this list only impacts the initial hosts used to discover the full set of servers. This list should be in the form host1:port1,host2:port2,.... Since these servers are just used for the initial connection to discover the full cluster membership (which may change dynamically), this list need not contain the full set of servers (you may want more than one, though, in case a server is down). Required.
12
+ # @option config [String] :key_deserializer Deserializer class for key that implements the Deserializer interface. Required.
13
+ # @option config [String] :value_deserializer Deserializer class for value that implements the Deserializer interface. Required.
14
+ # @option config [Array] :topics The topic to consume from. Required.
15
+ #
16
+ #
17
+ # For other configuration properties and their default values see
18
+ # http://kafka.apache.org/documentation.html#newconsumerconfigs and
19
+ # https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/ConsumerConfig.html.
20
+ #
21
+ def initialize(config={})
22
+ validate_arguments config
23
+ @properties = config.clone
24
+ @topics = @properties.delete :topics
25
+ @stop_called = Concurrent::AtomicBoolean.new(false)
26
+ @consumer = KAFKA_CONSUMER.new(create_config)
27
+ @subscribed = false
28
+ subscribe
29
+ end
30
+
31
+ attr_reader :properties, :topics
32
+
33
+ def stop
34
+ @stop_called.make_true
35
+ @consumer.wakeup
36
+ end
37
+
38
+ # Subscribe to topics
39
+ def subscribe
40
+ @consumer.subscribe(@topics)
41
+ @subscribed = true
42
+ nil
43
+ end
44
+
45
+ # stop? should never be overriden
46
+ def stop?
47
+ @stop_called.value
48
+ end
49
+
50
+ # Fetch data for the topics or partitions specified using one of the subscribe/assign APIs.
51
+ def poll(timeout)
52
+ @consumer.poll timeout
53
+ end
54
+
55
+ def close
56
+ @consumer.close
57
+ end
58
+
59
+ private
60
+
61
+ def validate_arguments(options)
62
+ [:bootstrap_servers, :key_deserializer, :value_deserializer].each do |opt|
63
+ raise ArgumentError, "Parameter :#{opt} is required." unless options[opt]
64
+ end
65
+ end
66
+
67
+ def create_config
68
+ properties = java.util.Properties.new
69
+ @properties.each do |k,v|
70
+ k = k.to_s.gsub '_', '.'
71
+ v = v.to_s
72
+ properties.setProperty k, v
73
+ end
74
+ properties
75
+ end
76
+ end
77
+
@@ -1,4 +1,4 @@
1
1
  module Kafka
2
- VERSION = '3.1'.freeze
2
+ VERSION = '3.2'.freeze
3
3
  JAR_DEPENDENCIES_VERSION = '0.3.2'.freeze
4
- end
4
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.1'
4
+ version: '3.2'
5
5
  platform: java
6
6
  authors:
7
7
  - Joseph Lawson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '='
17
+ - !ruby/object:Gem::Version
18
+ version: 1.0.0
19
+ name: concurrent-ruby
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  requirement: !ruby/object:Gem::Requirement
15
29
  requirements:
@@ -66,7 +80,7 @@ dependencies:
66
80
  - - ~>
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3.3'
69
- description: this is primarily to be used as an interface for logstash
83
+ description: A ready to go interface to Kafka for JRuby.
70
84
  email:
71
85
  - joe@joekiller.com
72
86
  executables: []
@@ -80,6 +94,7 @@ files:
80
94
  - lib/jruby-kafka.rb
81
95
  - lib/jruby-kafka/consumer.rb
82
96
  - lib/jruby-kafka/error.rb
97
+ - lib/jruby-kafka/kafka-consumer.rb
83
98
  - lib/jruby-kafka/kafka-producer.rb
84
99
  - lib/jruby-kafka/namespace.rb
85
100
  - lib/jruby-kafka/producer.rb