Repository navigation
Respect the DynamoDB scan page size #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dajiaohuang
wants to merge
7
commits into
laserdisc-io:main
Choose a base branch
from
dajiaohuang:fix-dynamodb-scan-pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b6931c3
Honor DynamoDB scan page size
dajiaohuang 142fe50
fix: keep scan validation effectful and test cancellation
dajiaohuang 6f39368
Merge branch 'main' into fix-dynamodb-scan-pages
dajiaohuang a7a8a0f
Merge branch 'main' into fix-dynamodb-scan-pages
barryoneill d02d279
Merge branch 'main' into fix-dynamodb-scan-pages
mergify[bot] d1216f3
Merge branch 'main' into fix-dynamodb-scan-pages
mergify[bot] 7273773
Merge branch 'main' into fix-dynamodb-scan-pages
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
52 changes: 52 additions & 0 deletions
52
fs2-aws-dynamodb/src/test/scala/fs2/aws/dynamodb/StreamScanCancellationSuite.scala
This file contains hidden or 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,52 @@ | ||
| package fs2.aws.dynamodb | ||
|
|
||
| import cats.effect.IO | ||
| import io.laserdisc.pure.dynamodb.tagless.DynamoDbAsyncClientOp | ||
| import munit.CatsEffectSuite | ||
| import org.mockito.ArgumentMatchers.any | ||
| import org.mockito.Mockito.{doAnswer, mock, verify, when} | ||
| import org.reactivestreams.{Subscriber, Subscription} | ||
| import software.amazon.awssdk.services.dynamodb.model.{ScanRequest, ScanResponse} | ||
| import software.amazon.awssdk.services.dynamodb.paginators.ScanPublisher | ||
|
|
||
| import java.util.concurrent.atomic.AtomicBoolean | ||
|
|
||
| class StreamScanCancellationSuite extends CatsEffectSuite { | ||
| test("invalid page sizes fail through the stream error channel") { | ||
| val ddb = mock(classOf[DynamoDbAsyncClientOp[IO]]) | ||
| StreamScan[IO](ddb) | ||
| .scanDynamoDB(ScanRequest.builder().build(), 0) | ||
| .compile | ||
| .drain | ||
| .attempt | ||
| .map(result => assert(result.left.exists(_.isInstanceOf[IllegalArgumentException]))) | ||
| } | ||
|
|
||
| test("early termination cancels the publisher subscription") { | ||
| val ddb = mock(classOf[DynamoDbAsyncClientOp[IO]]) | ||
| val publisher = mock(classOf[ScanPublisher]) | ||
| val subscription = mock(classOf[Subscription]) | ||
| val emitted = new AtomicBoolean(false) | ||
| when(ddb.scanPaginator(any(classOf[ScanRequest]))).thenReturn(IO.pure(publisher)) | ||
| doAnswer { invocation => | ||
| val subscriber = invocation.getArgument[Subscriber[ScanResponse]](0) | ||
| doAnswer { _ => | ||
| if (emitted.compareAndSet(false, true)) { | ||
| val thread = new Thread(() => subscriber.onNext(ScanResponse.builder().build())) | ||
| thread.setDaemon(true) | ||
| thread.start() | ||
| } | ||
| null | ||
| }.when(subscription).request(1L) | ||
| subscriber.onSubscribe(subscription) | ||
| null | ||
| }.when(publisher).subscribe(any(classOf[Subscriber[ScanResponse]])) | ||
|
|
||
| StreamScan[IO](ddb) | ||
| .scanDynamoDB(ScanRequest.builder().build(), 3) | ||
| .take(1) | ||
| .compile | ||
| .drain | ||
| .map(_ => verify(subscription).cancel()) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.