* QueueSource now drops after completion (#25349) * Resolve Johan's review comments
This commit is contained in:
parent
887c56b562
commit
07dfdef620
2 changed files with 14 additions and 0 deletions
|
|
@ -71,6 +71,17 @@ class QueueSourceSpec extends StreamSpec {
|
||||||
f.futureValue should ===(QueueOfferResult.Enqueued)
|
f.futureValue should ===(QueueOfferResult.Enqueued)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"reject elements when completed" in {
|
||||||
|
// Not using the materialized test sink leads to the 42 being enqueued but not emitted due to lack of demand.
|
||||||
|
// This will also not effectively complete the stream, hence there is enough time (no races) to offer 43
|
||||||
|
// and verify it is dropped.
|
||||||
|
val source = Source.queue[Int](42, OverflowStrategy.backpressure).to(TestSink.probe).run()
|
||||||
|
source.offer(42)
|
||||||
|
source.complete()
|
||||||
|
val f = source.offer(43)
|
||||||
|
f.futureValue should ===(QueueOfferResult.Dropped)
|
||||||
|
}
|
||||||
|
|
||||||
"buffer when needed" in {
|
"buffer when needed" in {
|
||||||
val s = TestSubscriber.manualProbe[Int]()
|
val s = TestSubscriber.manualProbe[Int]()
|
||||||
val queue = Source.queue(100, OverflowStrategy.dropHead).to(Sink.fromSubscriber(s)).run()
|
val queue = Source.queue(100, OverflowStrategy.dropHead).to(Sink.fromSubscriber(s)).run()
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,9 @@ import scala.util.control.NonFatal
|
||||||
}
|
}
|
||||||
|
|
||||||
private val callback = getAsyncCallback[Input[T]] {
|
private val callback = getAsyncCallback[Input[T]] {
|
||||||
|
case Offer(_, promise) if terminating ⇒
|
||||||
|
promise.success(QueueOfferResult.Dropped)
|
||||||
|
|
||||||
case offer @ Offer(elem, promise) ⇒
|
case offer @ Offer(elem, promise) ⇒
|
||||||
if (maxBuffer != 0) {
|
if (maxBuffer != 0) {
|
||||||
bufferElem(offer)
|
bufferElem(offer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue