Change tests to use new Source.queue api, #29801 (#30070)

This commit is contained in:
Alex 2021-05-27 10:53:18 +04:00 committed by GitHub
parent 48e4f11dfd
commit 3ae85e8cd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 27 deletions

View file

@ -749,8 +749,8 @@ public class IntegrationDocTest extends AbstractJavaTest {
int bufferSize = 10;
int elementsToProcess = 5;
SourceQueueWithComplete<Integer> sourceQueue =
Source.<Integer>queue(bufferSize, OverflowStrategy.backpressure())
BoundedSourceQueue<Integer> sourceQueue =
Source.<Integer>queue(bufferSize)
.throttle(elementsToProcess, Duration.ofSeconds(3))
.map(x -> x * x)
.to(Sink.foreach(x -> System.out.println("got: " + x)))

View file

@ -22,6 +22,7 @@ import scala.concurrent.ExecutionContext
import java.util.concurrent.atomic.AtomicInteger
import akka.stream.scaladsl.Flow
import org.scalacheck.Gen.const
object IntegrationDocSpec {
import TwitterStreamQuickstartDocSpec._
@ -469,7 +470,7 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
val elementsToProcess = 5
val queue = Source
.queue[Int](bufferSize, OverflowStrategy.backpressure)
.queue[Int](bufferSize)
.throttle(elementsToProcess, 3.second)
.map(x => x * x)
.toMat(Sink.foreach(x => println(s"completed $x")))(Keep.left)
@ -479,7 +480,7 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
implicit val ec = system.dispatcher
source
.mapAsync(1)(x => {
.map(x => {
queue.offer(x).map {
case QueueOfferResult.Enqueued => println(s"enqueued $x")
case QueueOfferResult.Dropped => println(s"dropped $x")