-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A stream can have multiple open shards at the same point in time. Handle this and various code cleanups.
- Loading branch information
1 parent
26e03f5
commit 93ffcee
Showing
3 changed files
with
140 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "dynamodb/stream/enumerator/version" | ||
require "aws-sdk-dynamodbstreams" | ||
|
||
module Dynamodb | ||
module Stream | ||
class Enumerator < ::Enumerator | ||
class ShardReader | ||
def initialize(client, shard_iterator) | ||
@client = client | ||
@shard_iterator = shard_iterator | ||
end | ||
|
||
def finished? | ||
@shard_iterator.nil? | ||
end | ||
|
||
def get_records(limit) | ||
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDBStreams/Client.html#get_records-instance_method | ||
resp = @client.get_records({ | ||
shard_iterator: @shard_iterator, | ||
limit: limit | ||
}) | ||
|
||
@shard_iterator = resp.next_shard_iterator | ||
|
||
resp.records | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters