Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.8.0
4c53115f921d524648c622bea369c213e05023bb
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runner.dialect = scala3
version = 3.7.17
version = 3.8.0
maxColumn = 120
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ object PekkoStreams extends PekkoStreams {
def limitBytes(stream: Source[ByteString, Any], maxBytes: Long): Source[ByteString, Any] = {
stream
.limitWeighted(maxBytes)(_.length.toLong)
.mapError {
case _: pekko.stream.StreamLimitReachedException => StreamMaxLengthExceededException(maxBytes)
.mapError { case _: pekko.stream.StreamLimitReachedException =>
StreamMaxLengthExceededException(maxBytes)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ class PekkoStreamsTest extends AnyFlatSpec with Matchers with BeforeAndAfterAll
val stream = PekkoStreams.limitBytes(inputStream, maxBytes)

// then
stream.fold(0L)((acc, bs) => acc + bs.length).runWith(TestSink[Long]()).request(1).expectNext(inputByteCount.toLong).expectComplete()
stream
.fold(0L)((acc, bs) => acc + bs.length)
.runWith(TestSink[Long]())
.request(1)
.expectNext(inputByteCount.toLong)
.expectComplete()
}

it should "Fail stream if limit is exceeded" in {
Expand All @@ -51,7 +56,7 @@ class PekkoStreamsTest extends AnyFlatSpec with Matchers with BeforeAndAfterAll
Source.fromIterator(() => iterator.grouped(chunkSize).map(group => ByteString(group.toArray)))

// when
val stream = PekkoStreams.limitBytes(inputStream, maxBytes)
val stream = PekkoStreams.limitBytes(inputStream, maxBytes)
val probe = stream.runWith(TestSink[ByteString]())
val _ = for (_ <- 1 to 31) yield probe.requestNext()

Expand Down