telekinesis 3.0.0-java → 3.1.0-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: b4fa22c623dd098fff1cefccc7b48d9c543858b3
4
- data.tar.gz: b3063eaed5976b9744ecc6eb13fa0fa05c42a184
3
+ metadata.gz: 64568f19bf5cb841186d4d33b5d1a3bbc3e83ee2
4
+ data.tar.gz: 95b27916188a9387a46094674ffcd3e3d9dcc4c5
5
5
  SHA512:
6
- metadata.gz: 58272a8819dae59636c4c0827da20d244675d2a0404795d2cb33a724643cd31c195c0a692623545483563d7a920257ea8536e0496e8f8b0d938c4fba824c0752
7
- data.tar.gz: 07ee614c9d050cd3b37e6d0a4d038dc3efea8e86704d4a2516b9c91ceb0c7efcbfc62d700f84b8f9234385fbd9152411253f0b286dd4c7f0c7470b4bd6627542
6
+ metadata.gz: 87b0c34a4b7183fd30d8954e95f40a0b65976c572fbfd8b550a6561f6874f2845720d062291dea7ad8855443ba6d33c50c1bf6d508ac9608338fc9b753ef8b1a
7
+ data.tar.gz: 36be781fe1fbc64944fff46e92417d7fc50a1c687b689beae7a69b1be1183cb562237f0a19f17da5f408c0e0fe3298c78eff6f3c78b9a55ba6f36cd5c5ec7ebc
data/README.md CHANGED
@@ -230,9 +230,11 @@ class MyProcessor
230
230
  end
231
231
  end
232
232
 
233
- Telekinesis::Consumer::KCL.new(stream: 'some-events', app: 'example') do
233
+ worker = Telekinesis::Consumer::KCL.new(stream: 'some-events', app: 'example') do
234
234
  MyProcessor.new
235
235
  end
236
+
237
+ worker.run
236
238
  ```
237
239
 
238
240
  To make defining record processors easier, Telekinesis comes with a `Block`
@@ -243,11 +245,13 @@ processor.
243
245
  ```ruby
244
246
  require 'telekinesis'
245
247
 
246
- Telekinesis::Consumer::KCL.new(stream: 'some-events', app: 'example') do
248
+ worker = Telekinesis::Consumer::KCL.new(stream: 'some-events', app: 'example') do
247
249
  Telekinesis::Consumer::Block.new do |records, checkpointer, millis_behind|
248
250
  records.each {|r| puts "key=#{r.partition_key} value=#{String.from_java_bytes(r.data.array)}" }
249
251
  end
250
252
  end
253
+
254
+ worker.run
251
255
  ```
252
256
 
253
257
  Once you get into building a client application, you'll probably want
data/ext/pom.xml CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <groupId>com.kickstarter</groupId>
6
6
  <artifactId>telekinesis</artifactId>
7
- <version>3.0.0</version>
7
+ <version>3.1.0</version>
8
8
 
9
9
  <!-- ================================================================== -->
10
10
  <build>
@@ -16,6 +16,8 @@ import com.amazonaws.services.kinesis.clientlibrary.types.ProcessRecordsInput;
16
16
  import com.amazonaws.services.kinesis.clientlibrary.types.ShutdownInput;
17
17
  import com.amazonaws.services.kinesis.model.Record;
18
18
 
19
+ import java.util.concurrent.ExecutorService;
20
+
19
21
  /**
20
22
  * A shim that makes it possible to use the Kinesis Client Library from JRuby.
21
23
  * Without the shim, {@code initialize} method in
@@ -24,16 +26,16 @@ import com.amazonaws.services.kinesis.model.Record;
24
26
  * interface renames {@code initialize} to {@code init}.
25
27
  * <p />
26
28
  *
27
- * For convenience a {@link #newWorker(KinesisClientLibConfiguration, IRecordProcessorFactory)}
29
+ * For convenience a {@link #newWorker(KinesisClientLibConfiguration, ExecutorService, IRecordProcessorFactory)}
28
30
  * method is provided, so you can use closure conversion in JRuby to specify an
29
31
  * {@link IRecordProcessorFactory}. For example
30
32
  *
31
33
  * <p />
32
34
  *
33
35
  * <pre>
34
- * some_thing = ...
36
+ * executor = config[:executor] || nil
35
37
  *
36
- * com.kickstarter.jruby.Telekinesis.new_worker(my_config) do
38
+ * com.kickstarter.jruby.Telekinesis.new_worker(my_config, executor) do
37
39
  * MyRecordProcessor.new(some_thing, some_other_thing)
38
40
  * end
39
41
  * </pre>
@@ -41,19 +43,23 @@ import com.amazonaws.services.kinesis.model.Record;
41
43
  public class Telekinesis {
42
44
  /**
43
45
  * Create a new KCL {@link Worker} that processes records using the given
44
- * {@link IRecordProcessorFactory}.
46
+ * {@link ExecutorService} and {@link IRecordProcessorFactory}.
45
47
  */
46
- public static Worker newWorker(final KinesisClientLibConfiguration config, final IRecordProcessorFactory factory) {
48
+ public static Worker newWorker(final KinesisClientLibConfiguration config,
49
+ final ExecutorService executor,
50
+ final IRecordProcessorFactory factory) {
47
51
  com.amazonaws.services.kinesis.clientlibrary.interfaces.v2.IRecordProcessorFactory v2Factory = new com.amazonaws.services.kinesis.clientlibrary.interfaces.v2.IRecordProcessorFactory() {
48
52
  @Override
49
53
  public com.amazonaws.services.kinesis.clientlibrary.interfaces.v2.IRecordProcessor createProcessor() {
50
54
  return new RecordProcessorShim(factory.createProcessor());
51
55
  }
52
56
  };
57
+
53
58
  return new Worker.Builder()
54
- .recordProcessorFactory(v2Factory)
55
- .config(config)
56
- .build();
59
+ .recordProcessorFactory(v2Factory)
60
+ .config(config)
61
+ .execService(executor) // NOTE: .execService(null) is a no-op
62
+ .build();
57
63
  }
58
64
 
59
65
  // ========================================================================
@@ -67,7 +67,7 @@ module Telekinesis
67
67
  def initialize(config, &block)
68
68
  raise ArgumentError, "No block given!" unless block_given?
69
69
  kcl_config = self.class.build_config(config)
70
- @under = com.kickstarter.jruby.Telekinesis.new_worker(kcl_config, &block)
70
+ @under = com.kickstarter.jruby.Telekinesis.new_worker(kcl_config, config[:executor], &block)
71
71
  end
72
72
 
73
73
  # Return the underlying KCL worker. It's a java.lang.Runnable.
@@ -97,6 +97,7 @@ module Telekinesis
97
97
  raise ArgumentError, "#{k} is required" unless config.include?(k)
98
98
  config[k]
99
99
  end
100
+
100
101
  # Use this host as the worker_id by default.
101
102
  worker_id = config.fetch(:worker_id, `hostname`.chomp)
102
103
 
@@ -1,3 +1,3 @@
1
1
  module Telekinesis
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telekinesis
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Ben Linsay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ files:
106
106
  - test/producer/test_helper.rb
107
107
  - test/producer/test_sync_producer.rb
108
108
  - test/test_helper.rb
109
- - lib/telekinesis/telekinesis-3.0.0.jar
109
+ - lib/telekinesis/telekinesis-3.1.0.jar
110
110
  homepage: https://github.com/kickstarter/telekinesis
111
111
  licenses: []
112
112
  metadata: {}