feat: Add create method to PFBuilder. (#947)

This commit is contained in:
He-Pin(kerr) 2024-01-15 17:37:14 +08:00 committed by GitHub
parent cf70478201
commit df302b8ee6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 18 deletions

View file

@ -260,7 +260,9 @@ public class BidiFlowDocTest extends AbstractJavaTest {
final Flow<Message, Message, NotUsed> pingpong =
Flow.of(Message.class)
.collect(
new PFBuilder<Message, Message>().match(Ping.class, p -> new Pong(p.id)).build());
PFBuilder.<Message, Message>create()
.match(Ping.class, p -> new Pong(p.id))
.build());
final Flow<Message, Message, NotUsed> flow = stack.atop(stack.reversed()).join(pingpong);
final CompletionStage<List<Message>> result =
Source.from(Arrays.asList(0, 1, 2))

View file

@ -156,7 +156,7 @@ public class FlowErrorDocTest extends AbstractJavaTest {
else return n.toString();
})
.recover(
new PFBuilder<Throwable, String>()
PFBuilder.<Throwable, String>create()
.match(RuntimeException.class, Throwable::getMessage)
.build())
.runForeach(System.out::println, system);
@ -187,7 +187,7 @@ public class FlowErrorDocTest extends AbstractJavaTest {
})
.recoverWithRetries(
1, // max attempts
new PFBuilder<Throwable, Source<String, NotUsed>>()
PFBuilder.<Throwable, Source<String, NotUsed>>create()
.match(RuntimeException.class, ex -> planB)
.build())
.runForeach(System.out::println, system);

View file

@ -62,7 +62,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
.backpressureTimeout(timeout)
.recoverWithRetries(
maxRetries,
new PFBuilder<Throwable, Source<T, NotUsed>>()
PFBuilder.<Throwable, Source<T, NotUsed>>create()
.match(
TimeoutException.class,
ex ->

View file

@ -395,7 +395,7 @@ class SourceOrFlow {
Flow<Message, Pong, NotUsed> flow =
Flow.of(Message.class)
.collect(
new PFBuilder<Message, Pong>()
PFBuilder.<Message, Pong>create()
.match(Ping.class, p -> p.id != 0, p -> new Pong(p.id))
.build());
// #collect