You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by fa...@apache.org on 2023/12/28 10:43:25 UTC

(incubator-pekko-connectors) branch main updated: Kinesis: fix maxBytesPerSecond throttling (#298)

This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-connectors.git


The following commit(s) were added to refs/heads/main by this push:
     new c53ba216b Kinesis: fix maxBytesPerSecond throttling (#298)
c53ba216b is described below

commit c53ba216b79ded5c8216cdb2506c9d05d7e379cc
Author: João Ferreira <jt...@gmail.com>
AuthorDate: Thu Dec 28 10:43:19 2023 +0000

    Kinesis: fix maxBytesPerSecond throttling (#298)
---
 .../pekko/stream/connectors/kinesis/scaladsl/KinesisFlow.scala   | 4 ++--
 .../apache/pekko/stream/connectors/kinesis/KinesisFlowSpec.scala | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/kinesis/src/main/scala/org/apache/pekko/stream/connectors/kinesis/scaladsl/KinesisFlow.scala b/kinesis/src/main/scala/org/apache/pekko/stream/connectors/kinesis/scaladsl/KinesisFlow.scala
index bb64d7a50..3c02937e5 100644
--- a/kinesis/src/main/scala/org/apache/pekko/stream/connectors/kinesis/scaladsl/KinesisFlow.scala
+++ b/kinesis/src/main/scala/org/apache/pekko/stream/connectors/kinesis/scaladsl/KinesisFlow.scala
@@ -104,8 +104,8 @@ object KinesisFlow {
       entries: Iterable[(PutRecordsRequestEntry, T)])(result: PutRecordsResponse): List[(PutRecordsResultEntry, T)] =
     result.records.asScala.toList.zip(entries).map { case (res, (_, t)) => (res, t) }
 
-  private def getPayloadByteSize[T](record: (PutRecordsRequestEntry, T)): Int = record match {
-    case (request, _) => request.partitionKey.length + request.data.asByteBuffer.position()
+  private[kinesis] def getPayloadByteSize[T](record: (PutRecordsRequestEntry, T)): Int = record match {
+    case (request, _) => request.partitionKey.length + request.data.asByteArrayUnsafe.length
   }
 
   def byPartitionAndData(
diff --git a/kinesis/src/test/scala/org/apache/pekko/stream/connectors/kinesis/KinesisFlowSpec.scala b/kinesis/src/test/scala/org/apache/pekko/stream/connectors/kinesis/KinesisFlowSpec.scala
index e430d9228..d124840a4 100644
--- a/kinesis/src/test/scala/org/apache/pekko/stream/connectors/kinesis/KinesisFlowSpec.scala
+++ b/kinesis/src/test/scala/org/apache/pekko/stream/connectors/kinesis/KinesisFlowSpec.scala
@@ -66,6 +66,15 @@ class KinesisFlowSpec extends AnyWordSpec with Matchers with KinesisMock with Lo
         sinkProbe.expectError(FailurePublishingRecords(requestError))
       }
     }
+
+    "compute payload size" in {
+      val r = PutRecordsRequestEntry
+        .builder()
+        .partitionKey("")
+        .data(SdkBytes.fromByteBuffer(ByteString("data").asByteBuffer))
+        .build()
+      KinesisFlow.getPayloadByteSize((r, "")) shouldBe 4
+    }
   }
 
   "KinesisFlowWithUserContext" must {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org