aws-kclrb 2.2.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +69 -66
- data/VERSION +1 -1
- data/lib/aws/kclrb/kcl_process.rb +2 -2
- data/pom.xml +25 -34
- data/spec/kcl_process_spec.rb +99 -41
- metadata +30 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3beff85e7553d852f6c1dfadd44ee7279fdb29256f2ed40fd98358b51751ae72
         | 
| 4 | 
            +
              data.tar.gz: 3c63d7db385a48655dfde264d574859084d71aa7eb5dd3f4642673e8076fca53
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8c6979336047673a21d5012c4ecd7afb23e51c51aa510b359b5520af40911ceff6a32db68f496fa6c55d2d9112ff9b754607e7a1d2badd47f8a4b943c84ad983
         | 
| 7 | 
            +
              data.tar.gz: b180e3db5cf893c5104cd2522eb5d997015f241be081d974f0f5deb317177d2934a95dc7ef6d805c4cc64d6d98c28581d9c21e0199bc32c7c6ccd3e66171d8cf
         | 
    
        data/README.md
    CHANGED
    
    | @@ -11,38 +11,38 @@ This package wraps and manages the interaction with the [MultiLangDaemon][multi- | |
| 11 11 | 
             
            executable. A record processor in Ruby typically looks something like:
         | 
| 12 12 |  | 
| 13 13 | 
             
            ```ruby
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 14 | 
            +
            #! /usr/bin/env ruby
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            require 'aws/kclrb'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            class SampleRecordProcessor < Aws::KCLrb::V2::RecordProcessorBase
         | 
| 19 | 
            +
              def init_processor(initialize_input)
         | 
| 20 | 
            +
                # initialize
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def process_records(process_records_input)
         | 
| 24 | 
            +
                # process batch of records
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 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
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            if __FILE__ == $0
         | 
| 41 | 
            +
              # Start the main processing loop
         | 
| 42 | 
            +
              record_processor = SampleRecordProcessor.new
         | 
| 43 | 
            +
              driver = Aws::KCLrb::KCLProcess.new(record_processor)
         | 
| 44 | 
            +
              driver.run
         | 
| 45 | 
            +
            end
         | 
| 46 46 | 
             
            ```
         | 
| 47 47 |  | 
| 48 48 | 
             
            ## Before You Get Started
         | 
| @@ -60,16 +60,6 @@ access. | |
| 60 60 | 
             
            For questions regarding [Amazon Kinesis Service][amazon-kinesis] and the client libraries please check the
         | 
| 61 61 | 
             
            [official documentation][amazon-kinesis-docs] as well as the [Amazon Kinesis Forums][kinesis-forum].
         | 
| 62 62 |  | 
| 63 | 
            -
            ## 🚨Important: Migration to Ruby KCL 2.2.0 or later with MultiLangDaemon - Credential Provider Changes Required
         | 
| 64 | 
            -
            Java KCL version 2.7.0 and later uses AWS SDK for Java 2.x instead of AWS SDK for Java 1.x. For the KCL Ruby 2.x versions,
         | 
| 65 | 
            -
            v2.2.0 is the first Ruby release to use Java KCL 2.7.0. All MultiLangDaemon users upgrading from earlier versions must update
         | 
| 66 | 
            -
            their credential provider configuration in the `.properties` file to use credentials provider name for AWS SDK for Java 2.x.
         | 
| 67 | 
            -
            Failure to do this will cause your multilang KCL application to fail during startup with credential provider construction errors.
         | 
| 68 | 
            -
            Please check the following link for the credentials provider mapping and MultiLangDaemon credentials provider configuration guide
         | 
| 69 | 
            -
             | 
| 70 | 
            -
            - [AWS SDK for Java 1.x to 2.x Credentials Provider Mapping](aws.amazon.com/sdk-for-java/latest/developer-guide/migration-client-credentials.html#credentials-changes-mapping)
         | 
| 71 | 
            -
            - [KCL Multilang Credentials Provider Configuration Guide](https://github.com/aws/amazon-kinesis-client/blob/master/docs/multilang/configuring-credential-providers.md)
         | 
| 72 | 
            -
             | 
| 73 63 | 
             
            ## Running the Sample
         | 
| 74 64 |  | 
| 75 65 | 
             
            Using the Amazon KCL for Ruby package requires the [MultiLangDaemon][multi-lang-daemon] which
         | 
| @@ -104,11 +94,11 @@ To run the data producer, run the following commands: | |
| 104 94 |  | 
| 105 95 | 
             
            #### Notes
         | 
| 106 96 |  | 
| 107 | 
            -
            * The [AWS Ruby SDK gem][aws-ruby-sdk-gem] needs to be installed as a pre-requisite. To install,
         | 
| 97 | 
            +
            * The [AWS Ruby SDK gem][aws-ruby-sdk-gem] for Kinesis needs to be installed as a pre-requisite. To install,
         | 
| 108 98 | 
             
              run:
         | 
| 109 99 |  | 
| 110 100 | 
             
              ```sh
         | 
| 111 | 
            -
                  sudo gem install aws-sdk
         | 
| 101 | 
            +
                  sudo gem install aws-sdk-kinesis
         | 
| 112 102 | 
             
              ```
         | 
| 113 103 |  | 
| 114 104 | 
             
            * The script `samples/sample_kcl_producer.rb` takes several parameters that you can use
         | 
| @@ -196,27 +186,40 @@ all languages. | |
| 196 186 | 
             
            * The [Amazon Kinesis Forum][kinesis-forum]
         | 
| 197 187 |  | 
| 198 188 | 
             
            ## Release Notes
         | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
            *  | 
| 202 | 
            -
            *  | 
| 203 | 
            -
            *  | 
| 204 | 
            -
            *  | 
| 205 | 
            -
             | 
| 206 | 
            -
             
         | 
| 207 | 
            -
             | 
| 208 | 
            -
            *  | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
            *  | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
            * [ | 
| 216 | 
            -
            *  | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
            *  | 
| 189 | 
            +
             | 
| 190 | 
            +
            ### Release 3.0.0 (November 6, 2024)
         | 
| 191 | 
            +
            * New lease assignment / load balancing algorithm
         | 
| 192 | 
            +
              * KCL 3.x introduces a new lease assignment and load balancing algorithm. It assigns leases among workers based on worker utilization metrics and throughput on each lease, replacing the previous lease count-based lease assignment algorithm.
         | 
| 193 | 
            +
              * When KCL detects higher variance in CPU utilization among workers, it proactively reassigns leases from over-utilized workers to under-utilized workers for even load balancing. This ensures even CPU utilization across workers and removes the need to over-provision the stream processing compute hosts.
         | 
| 194 | 
            +
            * Optimized DynamoDB RCU usage
         | 
| 195 | 
            +
              * KCL 3.x optimizes DynamoDB read capacity unit (RCU) usage on the lease table by implementing a global secondary index with leaseOwner as the partition key. This index mirrors the leaseKey attribute from the base lease table, allowing workers to efficiently discover their assigned leases by querying the index instead of scanning the entire table.
         | 
| 196 | 
            +
              * This approach significantly reduces read operations compared to earlier KCL versions, where workers performed full table scans, resulting in higher RCU consumption.
         | 
| 197 | 
            +
            * Graceful lease handoff
         | 
| 198 | 
            +
              * KCL 3.x introduces a feature called "graceful lease handoff" to minimize data reprocessing during lease reassignments. Graceful lease handoff allows the current worker to complete checkpointing of processed records before transferring the lease to another worker. For graceful lease handoff, you should implement checkpointing logic within the existing `shutdownRequested()` method.
         | 
| 199 | 
            +
              * This feature is enabled by default in KCL 3.x, but you can turn off this feature by adjusting the configuration property `isGracefulLeaseHandoffEnabled`.
         | 
| 200 | 
            +
              * While this approach significantly reduces the probability of data reprocessing during lease transfers, it doesn't completely eliminate the possibility. To maintain data integrity and consistency, it's crucial to design your downstream consumer applications to be idempotent. This ensures that the application can handle potential duplicate record processing without adverse effects.
         | 
| 201 | 
            +
            * New DynamoDB metadata management artifacts
         | 
| 202 | 
            +
              * KCL 3.x introduces two new DynamoDB tables for improved lease management:
         | 
| 203 | 
            +
                * Worker metrics table: Records CPU utilization metrics from each worker. KCL uses these metrics for optimal lease assignments, balancing resource utilization across workers. If CPU utilization metric is not available, KCL assigns leases to balance the total sum of shard throughput per worker instead.
         | 
| 204 | 
            +
                * Coordinator state table: Stores internal state information for workers. Used to coordinate in-place migration from KCL 2.x to KCL 3.x and leader election among workers.
         | 
| 205 | 
            +
              * Follow this [documentation](https://docs.aws.amazon.com/streams/latest/dev/kcl-migration-from-2-3.html#kcl-migration-from-2-3-IAM-permissions) to add required IAM permissions for your KCL application.
         | 
| 206 | 
            +
            * Other improvements and changes
         | 
| 207 | 
            +
              * Dependency on the AWS SDK for Java 1.x has been fully removed.
         | 
| 208 | 
            +
                * The Glue Schema Registry integration functionality no longer depends on AWS SDK for Java 1.x. Previously, it required this as a transient dependency.
         | 
| 209 | 
            +
                * Multilangdaemon has been upgraded to use AWS SDK for Java 2.x. It no longer depends on AWS SDK for Java 1.x.
         | 
| 210 | 
            +
              * `idleTimeBetweenReadsInMillis` (PollingConfig) now has a minimum default value of 200.
         | 
| 211 | 
            +
                * This polling configuration property determines the [publishers](https://github.com/awslabs/amazon-kinesis-client/blob/master/amazon-kinesis-client/src/main/java/software/amazon/kinesis/retrieval/polling/PrefetchRecordsPublisher.java) wait time between GetRecords calls in both success and failure cases. Previously, setting this value below 200 caused unnecessary throttling. This is because Amazon Kinesis Data Streams supports up to five read transactions per second per shard for shared-throughput consumers.
         | 
| 212 | 
            +
              * Shard lifecycle management is improved to deal with edge cases around shard splits and merges to ensure records continue being processed as expected.
         | 
| 213 | 
            +
            * Migration
         | 
| 214 | 
            +
              * The programming interfaces of KCL 3.x remain identical with KCL 2.x for an easier migration. For detailed migration instructions, please refer to the [Migrate consumers from KCL 2.x to KCL 3.x](https://docs.aws.amazon.com/streams/latest/dev/kcl-migration-from-2-3.html) page in the Amazon Kinesis Data Streams developer guide.
         | 
| 215 | 
            +
            * Configuration properties
         | 
| 216 | 
            +
              * New configuration properties introduced in KCL 3.x are listed in this [doc](https://github.com/awslabs/amazon-kinesis-client/blob/master/docs/kcl-configurations.md#new-configurations-in-kcl-3x).
         | 
| 217 | 
            +
              * Deprecated configuration properties in KCL 3.x are listed in this [doc](https://github.com/awslabs/amazon-kinesis-client/blob/master/docs/kcl-configurations.md#discontinued-configuration-properties-in-kcl-3x). You need to keep the deprecated configuration properties during the migration from any previous KCL version to KCL 3.x.
         | 
| 218 | 
            +
            * Metrics
         | 
| 219 | 
            +
              * New CloudWatch metrics introduced in KCL 3.x are explained in the [Monitor the Kinesis Client Library with Amazon CloudWatch](https://docs.aws.amazon.com/streams/latest/dev/monitoring-with-kcl.html) in the Amazon Kinesis Data Streams developer guide. The following operations are newly added in KCL 3.x:
         | 
| 220 | 
            +
                * `LeaseAssignmentManager`
         | 
| 221 | 
            +
                * `WorkerMetricStatsReporter`
         | 
| 222 | 
            +
                * `LeaseDiscovery`
         | 
| 220 223 |  | 
| 221 224 | 
             
            ### Release 2.1.1 (February 21, 2023)
         | 
| 222 225 | 
             
            * [#69](https://github.com/awslabs/amazon-kinesis-client-ruby/pull/69) Include `pom.xml` in the gemspec
         | 
| @@ -263,7 +266,7 @@ all languages. | |
| 263 266 | 
             
            [amazon-kcl]: http://docs.aws.amazon.com/kinesis/latest/dev/kinesis-record-processor-app.html
         | 
| 264 267 | 
             
            [amazon-kcl-github]: https://github.com/awslabs/amazon-kinesis-client
         | 
| 265 268 | 
             
            [amazon-kinesis-python-github]: https://github.com/awslabs/amazon-kinesis-client-python
         | 
| 266 | 
            -
            [multi-lang-daemon]: https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/ | 
| 269 | 
            +
            [multi-lang-daemon]: https://github.com/awslabs/amazon-kinesis-client/blob/master/amazon-kinesis-client-multilang/src/main/java/software/amazon/kinesis/multilang/package-info.java
         | 
| 267 270 | 
             
            [DefaultCredentialsProvider]: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.html
         | 
| 268 271 | 
             
            [kinesis-forum]: http://developer.amazonwebservices.com/connect/forum.jspa?forumID=169
         | 
| 269 272 | 
             
            [aws-ruby-sdk-gem]: https://rubygems.org/gems/aws-sdk
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            3.0.0
         | 
| @@ -52,8 +52,8 @@ module Aws | |
| 52 52 | 
             
                  # @param action [Hash] A hash that represents an action to take with
         | 
| 53 53 | 
             
                  #   appropriate attributes, as retrieved from {IOProxy#read_action}, e.g.
         | 
| 54 54 | 
             
                  #
         | 
| 55 | 
            -
                  #   - `{"action":"initialize","shardId":"shardId-123"}`
         | 
| 56 | 
            -
                  #   - `{"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}]}`
         | 
| 55 | 
            +
                  #   - `{"action":"initialize","shardId":"shardId-123","sequenceNumber":123}`
         | 
| 56 | 
            +
                  #   - `{"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}],"millisBehindLatest":"0"}`
         | 
| 57 57 | 
             
                  #   - `{"action":"shutdown","reason":"TERMINATE"}`
         | 
| 58 58 | 
             
                  # @raise [MalformedAction] if the action is missing expected attributes.
         | 
| 59 59 | 
             
                  def process_action(action)
         | 
    
        data/pom.xml
    CHANGED
    
    | @@ -2,14 +2,12 @@ | |
| 2 2 | 
             
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
         | 
| 3 3 | 
             
                <modelVersion>4.0.0</modelVersion>
         | 
| 4 4 | 
             
                <properties>
         | 
| 5 | 
            -
                    <awssdk.version>2. | 
| 6 | 
            -
                    < | 
| 7 | 
            -
                    < | 
| 8 | 
            -
                    <netty.version>4.2.4.Final</netty.version>
         | 
| 5 | 
            +
                    <awssdk.version>2.25.64</awssdk.version>
         | 
| 6 | 
            +
                    <kcl.version>3.0.0</kcl.version>
         | 
| 7 | 
            +
                    <netty.version>4.1.108.Final</netty.version>
         | 
| 9 8 | 
             
                    <netty-reactive.version>2.0.6</netty-reactive.version>
         | 
| 10 | 
            -
                    <fasterxml-jackson.version>2. | 
| 11 | 
            -
                     | 
| 12 | 
            -
                    <logback.version>1.3.15</logback.version>
         | 
| 9 | 
            +
                    <fasterxml-jackson.version>2.13.5</fasterxml-jackson.version>
         | 
| 10 | 
            +
                    <logback.version>1.3.14</logback.version>
         | 
| 13 11 | 
             
                </properties>
         | 
| 14 12 | 
             
                <dependencies>
         | 
| 15 13 | 
             
                    <dependency>
         | 
| @@ -32,6 +30,18 @@ | |
| 32 30 | 
             
                        <artifactId>dynamodb</artifactId>
         | 
| 33 31 | 
             
                        <version>${awssdk.version}</version>
         | 
| 34 32 | 
             
                    </dependency>
         | 
| 33 | 
            +
                    <!-- https://mvnrepository.com/artifact/software.amazon.awssdk/dynamodb-enhanced -->
         | 
| 34 | 
            +
                    <dependency>
         | 
| 35 | 
            +
                        <groupId>software.amazon.awssdk</groupId>
         | 
| 36 | 
            +
                        <artifactId>dynamodb-enhanced</artifactId>
         | 
| 37 | 
            +
                        <version>${awssdk.version}</version>
         | 
| 38 | 
            +
                    </dependency>
         | 
| 39 | 
            +
                    <!-- https://mvnrepository.com/artifact/com.amazonaws/dynamodb-lock-client -->
         | 
| 40 | 
            +
                    <dependency>
         | 
| 41 | 
            +
                        <groupId>com.amazonaws</groupId>
         | 
| 42 | 
            +
                        <artifactId>dynamodb-lock-client</artifactId>
         | 
| 43 | 
            +
                        <version>1.3.0</version>
         | 
| 44 | 
            +
                    </dependency>
         | 
| 35 45 | 
             
                    <dependency>
         | 
| 36 46 | 
             
                        <groupId>software.amazon.awssdk</groupId>
         | 
| 37 47 | 
             
                        <artifactId>cloudwatch</artifactId>
         | 
| @@ -172,16 +182,6 @@ | |
| 172 182 | 
             
                        <artifactId>identity-spi</artifactId>
         | 
| 173 183 | 
             
                        <version>${awssdk.version}</version>
         | 
| 174 184 | 
             
                    </dependency>
         | 
| 175 | 
            -
                    <dependency>
         | 
| 176 | 
            -
                        <groupId>software.amazon.awssdk</groupId>
         | 
| 177 | 
            -
                        <artifactId>retries-spi</artifactId>
         | 
| 178 | 
            -
                        <version>${awssdk.version}</version>
         | 
| 179 | 
            -
                    </dependency>
         | 
| 180 | 
            -
                    <dependency>
         | 
| 181 | 
            -
                        <groupId>software.amazon.awssdk</groupId>
         | 
| 182 | 
            -
                        <artifactId>retries</artifactId>
         | 
| 183 | 
            -
                        <version>${awssdk.version}</version>
         | 
| 184 | 
            -
                    </dependency>
         | 
| 185 185 | 
             
                    <dependency>
         | 
| 186 186 | 
             
                        <groupId>io.netty</groupId>
         | 
| 187 187 | 
             
                        <artifactId>netty-codec-http</artifactId>
         | 
| @@ -197,11 +197,6 @@ | |
| 197 197 | 
             
                        <artifactId>netty-codec</artifactId>
         | 
| 198 198 | 
             
                        <version>${netty.version}</version>
         | 
| 199 199 | 
             
                    </dependency>
         | 
| 200 | 
            -
                    <dependency>
         | 
| 201 | 
            -
                        <groupId>io.netty</groupId>
         | 
| 202 | 
            -
                        <artifactId>netty-codec-base</artifactId>
         | 
| 203 | 
            -
                        <version>${netty.version}</version>
         | 
| 204 | 
            -
                    </dependency>
         | 
| 205 200 | 
             
                    <dependency>
         | 
| 206 201 | 
             
                        <groupId>io.netty</groupId>
         | 
| 207 202 | 
             
                        <artifactId>netty-transport</artifactId>
         | 
| @@ -290,7 +285,7 @@ | |
| 290 285 | 
             
                    <dependency>
         | 
| 291 286 | 
             
                        <groupId>org.apache.commons</groupId>
         | 
| 292 287 | 
             
                        <artifactId>commons-lang3</artifactId>
         | 
| 293 | 
            -
                        <version>3. | 
| 288 | 
            +
                        <version>3.14.0</version>
         | 
| 294 289 | 
             
                    </dependency>
         | 
| 295 290 | 
             
                    <dependency>
         | 
| 296 291 | 
             
                        <groupId>org.slf4j</groupId>
         | 
| @@ -342,16 +337,6 @@ | |
| 342 337 | 
             
                        <artifactId>httpcore</artifactId>
         | 
| 343 338 | 
             
                        <version>4.4.15</version>
         | 
| 344 339 | 
             
                    </dependency>
         | 
| 345 | 
            -
                    <dependency>
         | 
| 346 | 
            -
                        <groupId>com.amazonaws</groupId>
         | 
| 347 | 
            -
                        <artifactId>aws-java-sdk-core</artifactId>
         | 
| 348 | 
            -
                        <version>${aws-java-sdk.version}</version>
         | 
| 349 | 
            -
                    </dependency>
         | 
| 350 | 
            -
                    <dependency>
         | 
| 351 | 
            -
                        <groupId>com.amazonaws</groupId>
         | 
| 352 | 
            -
                        <artifactId>aws-java-sdk-sts</artifactId>
         | 
| 353 | 
            -
                        <version>${aws-java-sdk.version}</version>
         | 
| 354 | 
            -
                    </dependency>
         | 
| 355 340 | 
             
                    <dependency>
         | 
| 356 341 | 
             
                        <groupId>com.amazon.ion</groupId>
         | 
| 357 342 | 
             
                        <artifactId>ion-java</artifactId>
         | 
| @@ -361,6 +346,12 @@ | |
| 361 346 | 
             
                        <groupId>software.amazon.glue</groupId>
         | 
| 362 347 | 
             
                        <artifactId>schema-registry-serde</artifactId>
         | 
| 363 348 | 
             
                        <version>1.1.19</version>
         | 
| 349 | 
            +
                        <exclusions>
         | 
| 350 | 
            +
                            <exclusion>
         | 
| 351 | 
            +
                                <groupId>com.amazonaws</groupId>
         | 
| 352 | 
            +
                                <artifactId>aws-java-sdk-sts</artifactId>
         | 
| 353 | 
            +
                            </exclusion>
         | 
| 354 | 
            +
                        </exclusions>
         | 
| 364 355 | 
             
                    </dependency>
         | 
| 365 356 | 
             
                    <dependency>
         | 
| 366 357 | 
             
                        <groupId>joda-time</groupId>
         | 
| @@ -408,4 +399,4 @@ | |
| 408 399 | 
             
                        <version>3.2.2</version>
         | 
| 409 400 | 
             
                    </dependency>
         | 
| 410 401 | 
             
                </dependencies>
         | 
| 411 | 
            -
            </project>
         | 
| 402 | 
            +
            </project>
         | 
    
        data/spec/kcl_process_spec.rb
    CHANGED
    
    | @@ -27,66 +27,124 @@ module Aws::KCLrb | |
| 27 27 | 
             
                  end
         | 
| 28 28 | 
             
                end
         | 
| 29 29 |  | 
| 30 | 
            -
                def  | 
| 31 | 
            -
                  checkpointer.checkpoint | 
| 30 | 
            +
                def shutdown_requested(checkpointer)
         | 
| 31 | 
            +
                  checkpointer.checkpoint
         | 
| 32 32 | 
             
                end
         | 
| 33 33 | 
             
              end
         | 
| 34 34 |  | 
| 35 | 
            +
              class TestRecordProcessorV2 < Aws::KCLrb::V2::RecordProcessorBase
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def init_processor(shard_id)
         | 
| 38 | 
            +
                  # no-op
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def shutdown_requested(shutdown_requested_input)
         | 
| 42 | 
            +
                  shutdown_requested_input.checkpointer.checkpoint
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def process_records(process_records_input)
         | 
| 46 | 
            +
                  last_seq = nil
         | 
| 47 | 
            +
                  records = process_records_input.records
         | 
| 48 | 
            +
                  records.each do |record|
         | 
| 49 | 
            +
                    last_seq = record['sequenceNumber']
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  if last_seq
         | 
| 53 | 
            +
                    checkpointer = process_records_input.checkpointer
         | 
| 54 | 
            +
                    begin
         | 
| 55 | 
            +
                      checkpointer.checkpoint(last_seq)
         | 
| 56 | 
            +
                    rescue CheckpointError => cpe
         | 
| 57 | 
            +
                      if cpe.value == 'ThrottlingException'
         | 
| 58 | 
            +
                        checkpointer.checkpoint(last_seq)
         | 
| 59 | 
            +
                      else
         | 
| 60 | 
            +
                        raise
         | 
| 61 | 
            +
                      end
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 35 68 | 
             
              describe KCLProcess do
         | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
                     | 
| 69 | 
            +
             | 
| 70 | 
            +
                input_specs = [
         | 
| 71 | 
            +
                  {:method => :init_processor, :action => 'initialize', :input => '{"action":"initialize","shardId":"shard-000001","sequenceNumber":123456789}'},
         | 
| 72 | 
            +
                  {:method => :process_records, :action => 'processRecords', :input => '{"action":"processRecords","records":[],"millisBehindLatest":0}'},
         | 
| 73 | 
            +
                  {:method => :shutdown, :action => 'shutdownRequested', :input => '{"action":"shutdownRequested","reason":"TERMINATE"}'}
         | 
| 74 | 
            +
                ]
         | 
| 75 | 
            +
                versions = [1, 2]
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                describe "#action_response" do
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  before(:each) do
         | 
| 80 | 
            +
                    @processor = double(RecordProcessorBase)
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                  input_specs.each do |input_spec|
         | 
| 84 | 
            +
                    versions.each do |version|
         | 
| 85 | 
            +
                      it "V#{version} should respond to #{input_spec[:method]} action by invoking the corresponding processor's method and write a status message to the output IO" do
         | 
| 86 | 
            +
                        allow(@processor).to receive(:version).and_return(version)
         | 
| 87 | 
            +
                        action_response_common_test(input_spec[:method], input_spec[:action], input_spec[:input], version)
         | 
| 88 | 
            +
                      end
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  def action_response_common_test(method, action, input, version)
         | 
| 93 | 
            +
                    if method == :shutdown
         | 
| 94 | 
            +
                      expected_shutdown_input = version == 1 ? Aws::KCLrb::CheckpointerImpl : Aws::KCLrb::V2::ShutdownRequestedInput
         | 
| 95 | 
            +
                      allow(@processor).to receive(:shutdown_requested).with(expected_shutdown_input).and_return(nil)
         | 
| 96 | 
            +
                    else
         | 
| 97 | 
            +
                      expect(@processor).to receive(method).once
         | 
| 98 | 
            +
                    end
         | 
| 99 | 
            +
                    input = StringIO.new(input)
         | 
| 48 100 | 
             
                    output = StringIO.new
         | 
| 49 101 | 
             
                    error = StringIO.new
         | 
| 50 | 
            -
                    driver = KCLProcess.new(processor, input, output, error)
         | 
| 102 | 
            +
                    driver = KCLProcess.new(@processor, input, output, error)
         | 
| 51 103 | 
             
                    driver.run
         | 
| 52 104 |  | 
| 53 | 
            -
                    expected_output = %Q[{"action":"status","responseFor":"#{ | 
| 54 | 
            -
                    expect( | 
| 55 | 
            -
                    expect( | 
| 56 | 
            -
                    expect( | 
| 105 | 
            +
                    expected_output = %Q[{"action":"status","responseFor":"#{action}"}]
         | 
| 106 | 
            +
                    expect(output.string.gsub(/\s+/, "")).to eq(expected_output.gsub(/\s+/, ""))
         | 
| 107 | 
            +
                    expect(error.string).to eq("")
         | 
| 108 | 
            +
                    expect(input.eof?).to eq(true)
         | 
| 57 109 | 
             
                  end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 110 | 
            +
             | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                describe "#run" do
         | 
| 114 | 
            +
                  versions.each do |version|
         | 
| 115 | 
            +
                    it "V#{version} should process a normal stream of actions and produce expected output" do
         | 
| 116 | 
            +
                      input_string = <<-INPUT
         | 
| 117 | 
            +
            {"action":"initialize","shardId":"shardId-123","sequenceNumber":123}
         | 
| 118 | 
            +
            {"action":"processRecords","records":[{"data":"bWVvdw==","partitionKey":"cat","sequenceNumber":"456"}],"millisBehindLatest":"0"}
         | 
| 62 119 | 
             
            {"action":"checkpoint","sequenceNumber":"456","error":"ThrottlingException"}
         | 
| 63 120 | 
             
            {"action":"checkpoint","sequenceNumber":"456"}
         | 
| 64 | 
            -
            {"action":" | 
| 121 | 
            +
            {"action":"shutdownRequested","reason":"TERMINATE"}
         | 
| 65 122 | 
             
            {"action":"checkpoint","sequenceNumber":"456"}
         | 
| 66 | 
            -
             | 
| 123 | 
            +
                      INPUT
         | 
| 67 124 |  | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 125 | 
            +
                      # NOTE: The first checkpoint is expected to fail
         | 
| 126 | 
            +
                      #       with a ThrottlingException and hence the
         | 
| 127 | 
            +
                      #       retry.
         | 
| 128 | 
            +
                      expected_output_string = <<-OUTPUT
         | 
| 72 129 | 
             
            {"action":"status","responseFor":"initialize"}
         | 
| 73 130 | 
             
            {"action":"checkpoint","sequenceNumber":"456"}
         | 
| 74 131 | 
             
            {"action":"checkpoint","sequenceNumber":"456"}
         | 
| 75 132 | 
             
            {"action":"status","responseFor":"processRecords"}
         | 
| 76 133 | 
             
            {"action":"checkpoint","sequenceNumber":null}
         | 
| 77 | 
            -
            {"action":"status","responseFor":" | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 134 | 
            +
            {"action":"status","responseFor":"shutdownRequested"}
         | 
| 135 | 
            +
                      OUTPUT
         | 
| 136 | 
            +
                      processor = version == 1 ? TestRecordProcessor.new : TestRecordProcessorV2.new
         | 
| 137 | 
            +
                      input = StringIO.new(input_string)
         | 
| 138 | 
            +
                      output = StringIO.new
         | 
| 139 | 
            +
                      error = StringIO.new
         | 
| 140 | 
            +
                      driver = KCLProcess.new(processor, input, output, error)
         | 
| 141 | 
            +
                      driver.run
         | 
| 85 142 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 143 | 
            +
                      # outputs should be same modulo some whitespaces
         | 
| 144 | 
            +
                      expect( output.string.gsub(/\s+/, "") ).to eq(expected_output_string.gsub(/\s+/, ""))
         | 
| 145 | 
            +
                      expect( error.string ).to eq("")
         | 
| 146 | 
            +
                      expect( input.eof? ).to eq(true)
         | 
| 147 | 
            +
                    end
         | 
| 90 148 | 
             
                  end
         | 
| 91 149 | 
             
                end
         | 
| 92 150 | 
             
              end
         | 
    
        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:  | 
| 4 | 
            +
              version: 3.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Amazon Web Services
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-11-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: multi_json
         | 
| @@ -24,6 +24,34 @@ dependencies: | |
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '1.0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rspec
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: simplecov
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 27 55 | 
             
            description: A ruby interface for the Amazon Kinesis Client Library MultiLangDaemon
         | 
| 28 56 | 
             
            email: 
         | 
| 29 57 | 
             
            executables: []
         |