aws-kclrb 1.0.1 → 2.1.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
- SHA1:
3
- metadata.gz: d55dfffb55a3d32554c63e4636b5c4bcd7612145
4
- data.tar.gz: a6257f914079ce6b9e28bfe03faba78d30a08e94
2
+ SHA256:
3
+ metadata.gz: e606b4662cdbb79ec9bc55dfc314c311fbffaa332d203cf84c386095173a3aea
4
+ data.tar.gz: 4c21857b56f8e596bcb3072ee706611b145a43214a87e12a349e870395bc5b0e
5
5
  SHA512:
6
- metadata.gz: fb02f6b1830d16ec02031c6d49d07487a54af4cadfe73fe774fd30f4ce3b11d5cbe369b795767954020fb3ad0387bd852d611bc2d54656d676b0f8dc9cf2749f
7
- data.tar.gz: cfb93c0609cd2b76065347622adb49372322c381199f81debd6f39593197a5b72d15e14766778695c57d7bc7ea1a35a0704be44bfae135a8dfeaa2b3aaf0b710
6
+ metadata.gz: 30a46ab76ecaafa685cc156aaa036bda590717a4d47ec82b96683eadb3f8a9ca893d76a73d361006450b5c44bee54356281459e3a764bf76929167c30798d14d
7
+ data.tar.gz: 416dcfc937ead185262d3ffe77f4d27fc90bb0c190865b98c323774074b925b0a8177746be39a7c1ca5ef6a46876ca460e23d45ce3971dd629ac597e902fc15b
data/LICENSE.txt CHANGED
@@ -1,40 +1,175 @@
1
1
 
2
- Amazon Software License
3
-
4
- This Amazon Software License (“License”) governs your use, reproduction, and distribution of the accompanying software as specified below.
5
- 1. Definitions
6
-
7
- “Licensor” means any person or entity that distributes its Work.
8
-
9
- “Software” means the original work of authorship made available under this License.
10
-
11
- “Work” means the Software and any additions to or derivative works of the Software that are made available under this License.
12
-
13
- The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the meaning as provided under U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work.
14
-
15
- Works, including the Software, are “made available” under this License by including in or with the Work either (a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License.
16
- 2. License Grants
17
-
18
- 2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense and distribute its Work and any resulting derivative works in any form.
19
-
20
- 2.2 Patent Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free patent license to make, have made, use, sell, offer for sale, import, and otherwise transfer its Work, in whole or in part. The foregoing license applies only to the patent claims licensable by Licensor that would be infringed by Licensor’s Work (or portion thereof) individually and excluding any combinations with any other materials or technology.
21
- 3. Limitations
22
-
23
- 3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you include a complete copy of this License with your distribution, and (c) you retain without modification any copyright, patent, trademark, or attribution notices that are present in the Work.
24
-
25
- 3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and distribution of your derivative works of the Work (“Your Terms”) only if (a) Your Terms provide that the use limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative works that are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution requirements in Section 3.1) will continue to apply to the Work itself.
26
-
27
- 3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use with the web services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon Web Services, Inc.
28
-
29
- 3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim, cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work, then your rights under this License from such Licensor (including the grants in Sections 2.1 and 2.2) will terminate immediately.
30
-
31
- 3.5 Trademarks. This License does not grant any rights to use any Licensor’s or its affiliates’ names, logos, or trademarks, except as necessary to reproduce the notices described in this License.
32
-
33
- 3.6 Termination. If you violate any term of this License, then your rights under this License (including the grants in Sections 2.1 and 2.2) will terminate immediately.
34
- 4. Disclaimer of Warranty.
35
-
36
- THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF M ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. SOME STATES’ CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
37
- 5. Limitation of Liability.
38
-
39
- EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
40
-
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
data/README.md CHANGED
@@ -15,17 +15,25 @@ executable. A record processor in Ruby typically looks something like:
15
15
 
16
16
  require 'aws/kclrb'
17
17
 
18
- class SampleRecordProcessor < Aws::KCLrb::RecordProcessorBase
19
- def init_processor(shard_id)
18
+ class SampleRecordProcessor < Aws::KCLrb::V2::RecordProcessorBase
19
+ def init_processor(initialize_input)
20
20
  # initialize
21
21
  end
22
22
 
23
- def process_records(records, checkpointer)
23
+ def process_records(process_records_input)
24
24
  # process batch of records
25
25
  end
26
26
 
27
- def shutdown(checkpointer, reason)
28
- # cleanup
27
+ def lease_lost(lease_lost_input)
28
+ # lease was lost, cleanup
29
+ end
30
+
31
+ def shard_ended(shard_ended_input)
32
+ # shard has ended, cleanup
33
+ end
34
+
35
+ def shutdown_requested(shutdown_requested_input)
36
+ # shutdown has been requested
29
37
  end
30
38
  end
31
39
 
@@ -69,10 +77,11 @@ The sample application consists of two components:
69
77
  The following defaults are used in the sample application:
70
78
 
71
79
  * *Stream name*: `kclrbsample`
80
+ * *Region*: `us-east-1`
72
81
  * *Number of shards*: 2
73
82
  * *Amazon KCL application name*: `RubyKCLSample`
74
- * *Amazon DynamoDB table for Amazon KCL application*: `RubyKCLSample`
75
- * *Sample application output directory*: `/tmp/kclrbsample/`
83
+ * *Amazon DynamoDB table for KCL application*: `RubyKCLSample`
84
+ * *Amazon CloudWatch metrics namespace for KCL application*: `RubyKCLSample`
76
85
 
77
86
  ### Running the Data Producer
78
87
 
@@ -105,7 +114,7 @@ To run the data processor, run the following commands:
105
114
 
106
115
  ```sh
107
116
  cd samples
108
- rake run
117
+ rake run properties_file=sample.properties
109
118
  ```
110
119
 
111
120
  #### Notes
@@ -118,6 +127,7 @@ To run the data processor, run the following commands:
118
127
  * `executableName = samples/sample_kcl.rb`
119
128
  * `streamName = kclrbsample`
120
129
  * `applicationName = RubyKCLSample`
130
+ * `regionName = us-east-1`
121
131
 
122
132
  ### Cleaning Up
123
133
 
@@ -126,7 +136,7 @@ create a real DynamoDB table to track the Amazon KCL application state, thus pot
126
136
  incurring AWS costs. Once done, you can log in to AWS management console and delete these
127
137
  resources. Specifically, the sample application will create in your default AWS region
128
138
 
129
- * an *Amazon Kinesis stream* named `kclrbsample`
139
+ * an *Amazon Kinesis Data Stream* named `kclrbsample`
130
140
  * an *Amazon DynamoDB table* named `RubyKCLSample`
131
141
 
132
142
  ## Running on Amazon EC2
@@ -147,7 +157,7 @@ Amazon Linux can be found at `/usr/bin/java` and should be 1.7 or greater.
147
157
  cd kclrb/samples
148
158
  rake run_producer
149
159
  # ... and in another terminal
150
- rake run
160
+ rake run properties_file=sample.properties
151
161
  ```
152
162
 
153
163
  ## Under the Hood - What You Should Know about Amazon KCL's [MultiLangDaemon][multi-lang-daemon]
@@ -177,6 +187,36 @@ all languages.
177
187
 
178
188
  ## Release Notes
179
189
 
190
+ ### Release 2.1.0 (January 12, 2023)
191
+ * Upgraded to use version 2.4.4 of the [Amazon Kinesis Client library][amazon-kcl-github]
192
+
193
+ ### Release 2.0.0 (February 26, 2019)
194
+ * Added support for [Enhanced Fan-Out](https://aws.amazon.com/blogs/aws/kds-enhanced-fanout/).
195
+ Enhanced Fan-Out provides dedicated throughput per stream consumer, and uses an HTTP/2 push API (SubscribeToShard) to deliver records with lower latency.
196
+ * Updated the Amazon Kinesis Client Library for Java to version 2.1.2.
197
+ * Version 2.1.2 uses 4 additional Kinesis API's
198
+ __WARNING: These additional API's may require updating any explicit IAM policies__
199
+ * [`RegisterStreamConsumer`](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_RegisterStreamConsumer.html)
200
+ * [`SubscribeToShard`](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_SubscribeToShard.html)
201
+ * [`DescribeStreamConsumer`](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStreamConsumer.html)
202
+ * [`DescribeStreamSummary`](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStreamSummary.html)
203
+ * For more information about Enhanced Fan-Out with the Amazon Kinesis Client Library please see the [announcement](https://aws.amazon.com/blogs/aws/kds-enhanced-fanout/) and [developer documentation](https://docs.aws.amazon.com/streams/latest/dev/introduction-to-enhanced-consumers.html).
204
+ * Added version 2 of the [`RecordProcessorBase`](https://github.com/awslabs/amazon-kinesis-client-ruby/blob/d5c2bbafb232b5e1ab947980a0bd8505c87978f9/lib/aws/kclrb/record_processor.rb#L102) which supports the new `ShardRecordProcessor` interface
205
+ * The `shutdown` method from version 1 has been replaced by `lease_lost` and `shard_ended`.
206
+ * Added the `lease_lost` method which is invoked when a lease is lost.
207
+ `lease_lost` replaces `shutdown(checkpointer, 'ZOMBIE')`.
208
+ * Added the `shard_ended` method which is invoked when all records from a split or merge have been processed.
209
+ `shard_ended` replaces `shutdown(checkpointer, 'TERMINATE')`.
210
+ * Added an optional method, `shutdown_requested`, which provides the record processor a last chance to checkpoint during the Amazon Kinesis Client Library shutdown process before the lease is canceled.
211
+ * To control how long the Amazon Kinesis Client Library waits for the record processors to complete shutdown, add `timeoutInSeconds=<seconds to wait>` to your properties file.
212
+ * Updated the AWS Java SDK version to 2.4.0
213
+ * MultiLangDaemon now provides logging using Logback.
214
+ * MultiLangDaemon supports custom configurations for logging via a Logback XML configuration file.
215
+ * The example [Rakefile](https://github.com/awslabs/amazon-kinesis-client-ruby/blob/master/samples/Rakefile) supports setting the logging configuration by adding `log_configuration=<log configuration file>` to the Rake command line.
216
+
217
+ ### Release 1.0.1 (January 19, 2017)
218
+ * Upgraded to use version 1.7.2 of the [Amazon Kinesis Client library][amazon-kcl-github]
219
+
180
220
  ### Release 1.0.0 (December 30, 2014)
181
221
  * **aws-kclrb** gem which exposes an interface to allow implementation of record processors in Ruby
182
222
  using the Amazon KCL's [MultiLangDaemon][multi-lang-daemon]
@@ -193,3 +233,7 @@ all languages.
193
233
  [DefaultAWSCredentialsProviderChain]: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html
194
234
  [kinesis-forum]: http://developer.amazonwebservices.com/connect/forum.jspa?forumID=169
195
235
  [aws-ruby-sdk-gem]: https://rubygems.org/gems/aws-sdk
236
+
237
+ ## License
238
+
239
+ This library is licensed under the Apache 2.0 License.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 2.1.0
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/io_proxy'
16
6
 
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
  #
15
5
 
16
6
  require 'multi_json'
@@ -1,26 +1,19 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/io_proxy'
16
6
  require 'aws/kclrb/checkpointer'
7
+ require 'aws/kclrb/messages'
8
+ require 'aws/kclrb/record_processor'
17
9
 
18
10
  module Aws
19
11
  module KCLrb
20
12
  # Error raised if the {KCLProcess} received an input action that it
21
13
  # could not parse or it could not handle.
22
- class MalformedAction < RuntimeError; end
23
-
14
+ class MalformedAction < RuntimeError;
15
+ end
16
+
24
17
  # Entry point for a KCL application in Ruby.
25
18
  #
26
19
  # Implementers of KCL applications in Ruby should instantiate this
@@ -31,12 +24,16 @@ module Aws
31
24
  # @param input [IO] An `IO`-like object to read input lines from.
32
25
  # @param output [IO] An `IO`-like object to write output lines to.
33
26
  # @param error [IO] An `IO`-like object to write error lines to.
34
- def initialize(processor, input=$stdin, output=$stdout, error=$stderr)
35
- @processor = processor
27
+ def initialize(processor, input = $stdin, output = $stdout, error = $stderr)
28
+ if processor.version == 1
29
+ @processor = Aws::KCLrb::V2::V2ToV1Adapter.new(processor)
30
+ else
31
+ @processor = processor
32
+ end
36
33
  @io_proxy = IOProxy.new(input, output, error)
37
34
  @checkpointer = CheckpointerImpl.new(@io_proxy)
38
35
  end
39
-
36
+
40
37
  # Starts this KCL processor's main loop.
41
38
  def run
42
39
  action = @io_proxy.read_action
@@ -45,9 +42,9 @@ module Aws
45
42
  action = @io_proxy.read_action
46
43
  end
47
44
  end
48
-
45
+
49
46
  private
50
-
47
+
51
48
  # @api private
52
49
  # Parses an input action and invokes the appropriate method of the
53
50
  # record processor.
@@ -63,11 +60,20 @@ module Aws
63
60
  action_name = action.fetch('action')
64
61
  case action_name
65
62
  when 'initialize'
66
- dispatch_to_processor(:init_processor, action.fetch('shardId'))
63
+ dispatch_to_processor(:init_processor,
64
+ Aws::KCLrb::V2::InitializeInput.new(action.fetch('shardId'),
65
+ action.fetch('sequenceNumber')))
67
66
  when 'processRecords'
68
- dispatch_to_processor(:process_records, action.fetch('records'), @checkpointer)
69
- when 'shutdown'
70
- dispatch_to_processor(:shutdown, @checkpointer, action.fetch('reason'))
67
+ dispatch_to_processor(:process_records,
68
+ Aws::KCLrb::V2::ProcessRecordsInput.new(action.fetch('records'),
69
+ action.fetch('millisBehindLatest'),
70
+ @checkpointer))
71
+ when 'leaseLost'
72
+ dispatch_to_processor(:lease_lost, Aws::KCLrb::V2::LeaseLostInput.new)
73
+ when 'shardEnded'
74
+ dispatch_to_processor(:shard_ended, Aws::KCLrb::V2::ShardEndedInput.new(@checkpointer))
75
+ when 'shutdownRequested'
76
+ dispatch_to_processor(:shutdown_requested, Aws::KCLrb::V2::ShutdownRequestedInput.new(@checkpointer))
71
77
  else
72
78
  raise MalformedAction.new("Received an action which couldn't be understood. Action was '#{action}'")
73
79
  end
@@ -75,7 +81,7 @@ module Aws
75
81
  rescue KeyError => ke
76
82
  raise MalformedAction.new("Action '#{action}': #{ke.message}")
77
83
  end
78
-
84
+
79
85
  # @api private
80
86
  # Calls the specified method on the record processor, and handles
81
87
  # any resulting exceptions by writing to the error stream.
@@ -89,7 +95,7 @@ module Aws
89
95
  # of issue.
90
96
  @io_proxy.write_error(processor_error)
91
97
  end
92
-
98
+
93
99
  end
94
100
  end
95
101
  end
@@ -0,0 +1,53 @@
1
+ module Aws
2
+ module KCLrb
3
+ module V2
4
+ # @abstract
5
+ # Input object for RecordProcessorBase#init_processor method.
6
+ class InitializeInput
7
+ attr_reader :shard_id, :sequence_number
8
+
9
+ def initialize(shard_id, sequence_number)
10
+ @shard_id = shard_id
11
+ @sequence_number = sequence_number
12
+ end
13
+ end
14
+
15
+ # @abstract
16
+ # Input object for RecordProcessorBase#process_records method.
17
+ class ProcessRecordsInput
18
+ attr_reader :records, :millis_behind_latest, :checkpointer
19
+
20
+ def initialize(records, millis_behind_latest, checkpointer = nil)
21
+ @records = records
22
+ @millis_behind_latest = millis_behind_latest
23
+ @checkpointer = checkpointer
24
+ end
25
+ end
26
+
27
+ # @abstract
28
+ # Input object for RecordProcessorBase#lease_lost method.
29
+ class LeaseLostInput
30
+ end
31
+
32
+ # @abstract
33
+ # Input object forRecordProcessorBase#shard_ended method.
34
+ class ShardEndedInput
35
+ attr_reader :checkpointer
36
+
37
+ def initialize(checkpointer = nil)
38
+ @checkpointer = checkpointer
39
+ end
40
+ end
41
+
42
+ # @abstract
43
+ # Input object for RecordProcessorBase#shutdown_requested method.
44
+ class ShutdownRequestedInput
45
+ attr_reader :checkpointer
46
+
47
+ def initialize(checkpointer = nil)
48
+ @checkpointer = checkpointer
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,16 +1,6 @@
1
1
  #
2
- # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
2
+ # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  module Aws
16
6
  module KCLrb
@@ -32,7 +22,7 @@ module Aws
32
22
  def init_processor(shard_id)
33
23
  fail NotImplementedError.new
34
24
  end
35
-
25
+
36
26
  # @abstract
37
27
  # Called by a KCLProcess with a list of records to be processed and a checkpointer
38
28
  # which accepts sequence numbers from the records to indicate where in the stream
@@ -52,7 +42,7 @@ module Aws
52
42
  def process_records(records, checkpointer)
53
43
  fail NotImplementedError.new
54
44
  end
55
-
45
+
56
46
  # @abstract
57
47
  # Called by a KCLProcess instance to indicate that this record processor
58
48
  # should shutdown. After this is called, there will be no more calls to
@@ -72,6 +62,118 @@ module Aws
72
62
  def shutdown(checkpointer, reason)
73
63
  fail NotImplementedError.new
74
64
  end
65
+
66
+ # @abstract
67
+ # Called by a KCLProcess instance to indicate that this record processor
68
+ # is requesting a shutdown. This method should be overriden if required.
69
+ #
70
+ # @param checkpointer [Checkpointer] A checkpointer which accepts a sequence
71
+ # number or no parameters.
72
+ def shutdown_requested(checkpointer)
73
+ end
74
+
75
+ def version
76
+ 1
77
+ end
78
+ end
79
+
80
+ module V2
81
+ # @abstract
82
+ # Base class for implementing a record processor.
83
+ #
84
+ # A `RecordProcessor` processes a shard in a stream. See {https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/interfaces/IRecordProcessor.java the corresponding KCL interface}.
85
+ # Its methods will be called as follows:
86
+ #
87
+ # 1. {#init_processor} will be called once
88
+ # 2. {#process_records} will be called zero or more times
89
+ # 3. {#lease_lost} will be called zero to one time
90
+ # 4. {#shard_ended} will be called zero or more times
91
+ # 5. {#shutdown_requested} will be called zero to one time
92
+ class RecordProcessorBase
93
+ # @abstract
94
+ # Called once by a KCLProcess before any calls to process_records.
95
+ #
96
+ # @param initialize_input [InitializeInput] Initialize processor input
97
+ # object
98
+ def init_processor(initialize_input)
99
+ fail NotImplementedError.new
100
+ end
101
+
102
+ # @abstract
103
+ # Called by a KCLProcess with a list of records to be processed and a
104
+ # checkpointer which accepts sequence numbers from the records to
105
+ # indicate where in the stream to checkpoint.
106
+ #
107
+ # @param record_processor_input [RecordProcessorInput] Process records
108
+ # input object
109
+ def process_records(process_records_input)
110
+ fail NotImplementedError.new
111
+ end
112
+
113
+ # @abstract
114
+ # Called by a KCLProcess instance to indicate that this record processor
115
+ # should shutdown. After this is called, there will be no more calls to
116
+ # any other methods of this record processor.
117
+ #
118
+ # @param lease_lost_input [LeaseLostInput] Lease lost input object
119
+ #
120
+ # - Clients should not checkpoint because there is possibly another
121
+ # record processor which has acquired the lease for this shard.
122
+ def lease_lost(lease_lost_input)
123
+ fail NotImplementedError.new
124
+ end
125
+
126
+ # @abstract
127
+ # Called by a KCLProcess instance to indicate that this record processor
128
+ # should shutdown. After this is called, there will be no more calls to
129
+ # any other methods of this record processor.
130
+ #
131
+ # @param shard_ended_input [ShardEndedInput] Shard ended input object
132
+ #
133
+ # - Clients need to checkpoint at this time.
134
+ def shard_ended(shard_ended_input)
135
+ fail NotImplementedError.new
136
+ end
137
+
138
+ # @abstract
139
+ # Called by a KCLProcess instance to indicate that this record processor
140
+ # is requesting a shutdown. This method should be overriden if required.
141
+ #
142
+ # @param shutdown_requested_input [ShutdownRequestedInput]
143
+ def shutdown_requested(shutdown_requested_input)
144
+ end
145
+
146
+ def version
147
+ 2
148
+ end
149
+ end
150
+
151
+ class V2ToV1Adapter < Aws::KCLrb::V2::RecordProcessorBase
152
+ def initialize(processor)
153
+ @processor = processor
154
+ end
155
+
156
+ def init_processor(initialize_input)
157
+ @processor.init_processor(initialize_input.shard_id)
158
+ end
159
+
160
+ def process_records(process_records_input)
161
+ @processor.process_records(process_records_input.records,
162
+ process_records_input.checkpointer)
163
+ end
164
+
165
+ def lease_lost(lease_lost_input)
166
+ @processor.shutdown(nil, 'ZOMBIE')
167
+ end
168
+
169
+ def shard_ended(shard_ended_input)
170
+ @processor.shutdown(shard_ended_input.checkpointer, 'TERMINATE')
171
+ end
172
+
173
+ def shutdown_requested(shutdown_requested_input)
174
+ @processor.shutdown_requested(shutdown_requested_input.checkpointer)
175
+ end
176
+ end
75
177
  end
76
178
  end
77
179
  end
data/lib/aws/kclrb.rb CHANGED
@@ -1,16 +1,7 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/record_processor'
6
+ require 'aws/kclrb/messages'
16
7
  require 'aws/kclrb/kcl_process'
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/io_proxy.rb'
16
6
  require 'aws/kclrb/checkpointer.rb'
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/io_proxy'
16
6
 
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'aws/kclrb/kcl_process'
16
6
  require 'aws/kclrb/record_processor'
data/spec/spec_helper.rb CHANGED
@@ -1,16 +1,6 @@
1
1
  #
2
2
  # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
7
- #
8
- # http://aws.amazon.com/asl/
9
- #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
3
+ # SPDX-License-Identifier: Apache-2.0
14
4
 
15
5
  require 'simplecov'
16
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-kclrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  description: A ruby interface for the Amazon Kinesis Client Library MultiLangDaemon
28
- email:
28
+ email:
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
@@ -40,6 +40,7 @@ files:
40
40
  - lib/aws/kclrb/checkpointer.rb
41
41
  - lib/aws/kclrb/io_proxy.rb
42
42
  - lib/aws/kclrb/kcl_process.rb
43
+ - lib/aws/kclrb/messages.rb
43
44
  - lib/aws/kclrb/record_processor.rb
44
45
  - spec/checkpointer_spec.rb
45
46
  - spec/io_proxy_spec.rb
@@ -47,9 +48,9 @@ files:
47
48
  - spec/spec_helper.rb
48
49
  homepage: http://github.com/aws/amazon-kinesis-client-ruby
49
50
  licenses:
50
- - Amazon Software License
51
+ - Apache-2.0
51
52
  metadata: {}
52
- post_install_message:
53
+ post_install_message:
53
54
  rdoc_options: []
54
55
  require_paths:
55
56
  - lib
@@ -64,9 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  - !ruby/object:Gem::Version
65
66
  version: '0'
66
67
  requirements: []
67
- rubyforge_project:
68
- rubygems_version: 2.5.2
69
- signing_key:
68
+ rubygems_version: 3.3.11
69
+ signing_key:
70
70
  specification_version: 4
71
71
  summary: Amazon Kinesis Client Library for Ruby
72
72
  test_files: []