File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
agentic/src/test/java/io/serverlessworkflow/fluent/agentic
func/src/main/java/io/serverlessworkflow/fluent/func Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,13 @@ void chat_bot() {
7070 t .listen (
7171 "listenToMessages" ,
7272 l ->
73- l .one (c -> c .with (event -> event .type ("org.acme.chatbot.request" ))))
74- .when (message -> !"" .equals (message .get ("message" )), Map .class )
73+ l .until (message -> "" .equals (message .get ("message" )), Map .class )
74+ .one (
75+ c ->
76+ c .with (
77+ event -> event .type ("org.acme.chatbot.request" ))))
7578 .agent (chatBot )
76- .emit (emit -> emit .event (e -> e .type ("org.acme.chatbot.reply" )))
77- .then ("listenToMessages" ))
79+ .emit (emit -> emit .event (e -> e .type ("org.acme.chatbot.reply" ))))
7880 .build ();
7981
8082 try (WorkflowApplication app = WorkflowApplication .builder ().build ()) {
Original file line number Diff line number Diff line change 1515 */
1616package io .serverlessworkflow .fluent .func ;
1717
18+ import io .serverlessworkflow .api .types .AnyEventConsumptionStrategy ;
19+ import io .serverlessworkflow .api .types .ListenTask ;
20+ import io .serverlessworkflow .api .types .func .UntilPredicate ;
1821import io .serverlessworkflow .fluent .func .spi .ConditionalTaskBuilder ;
1922import io .serverlessworkflow .fluent .func .spi .FuncTransformations ;
2023import io .serverlessworkflow .fluent .spec .ListenTaskBuilder ;
24+ import java .util .function .Predicate ;
2125
2226public class FuncListenTaskBuilder extends ListenTaskBuilder
2327 implements ConditionalTaskBuilder <FuncListenTaskBuilder >,
2428 FuncTransformations <FuncListenTaskBuilder > {
2529
30+ private UntilPredicate untilPredicate ;
31+
2632 FuncListenTaskBuilder () {
2733 super ();
2834 }
35+
36+ public <T > FuncListenTaskBuilder until (Predicate <T > predicate , Class <T > predClass ) {
37+ untilPredicate = new UntilPredicate ().withPredicate (predicate , predClass );
38+ return this ;
39+ }
40+
41+ @ Override
42+ public ListenTask build () {
43+ ListenTask task = super .build ();
44+ AnyEventConsumptionStrategy anyEvent =
45+ task .getListen ().getTo ().getAnyEventConsumptionStrategy ();
46+ if (untilPredicate != null && anyEvent != null ) {
47+ anyEvent .withUntil (untilPredicate );
48+ }
49+ return task ;
50+ }
2951}
You can’t perform that action at this time.
0 commit comments