Skip to content

Commit 89021d0

Browse files
Add type safe API to execute an async update workflow request (#2320)
Add typed safe async update API
1 parent a2dd369 commit 89021d0

File tree

6 files changed

+913
-4
lines changed

6 files changed

+913
-4
lines changed

temporal-sdk/src/main/java/io/temporal/client/WorkflowClient.java

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,291 @@ static <A1, A2, A3, A4, A5, A6, R> WorkflowExecution start(
572572
return WorkflowClientInternalImpl.start(workflow, arg1, arg2, arg3, arg4, arg5, arg6);
573573
}
574574

575+
/**
576+
* Start a zero argument workflow update with a void return type
577+
*
578+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
579+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
580+
* @param options update options
581+
* @return WorkflowUpdateHandle that can be used to get the result of the update
582+
*/
583+
static WorkflowUpdateHandle<Void> startUpdate(
584+
Functions.Proc updateMethod, @Nonnull UpdateOptions<Void> options) {
585+
return WorkflowClientInternalImpl.startUpdate(updateMethod, options);
586+
}
587+
588+
/**
589+
* Start a one argument workflow update with a void return type
590+
*
591+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
592+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
593+
* @param arg1 first update method parameter
594+
* @param options update options
595+
* @return WorkflowUpdateHandle that can be used to get the result of the update
596+
*/
597+
static <A1> WorkflowUpdateHandle<Void> startUpdate(
598+
Functions.Proc1<A1> updateMethod, A1 arg1, @Nonnull UpdateOptions<Void> options) {
599+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, options);
600+
}
601+
602+
/**
603+
* Start a two argument workflow update with a void return type
604+
*
605+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
606+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
607+
* @param arg1 first update method parameter
608+
* @param arg2 second update method parameter
609+
* @param options update options
610+
* @return WorkflowUpdateHandle that can be used to get the result of the update
611+
*/
612+
static <A1, A2> WorkflowUpdateHandle<Void> startUpdate(
613+
Functions.Proc2<A1, A2> updateMethod,
614+
A1 arg1,
615+
A2 arg2,
616+
@Nonnull UpdateOptions<Void> options) {
617+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, options);
618+
}
619+
620+
/**
621+
* Start a three argument workflow update with a void return type
622+
*
623+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
624+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
625+
* @param arg1 first update method parameter
626+
* @param arg2 second update method parameter
627+
* @param arg3 third update method parameter
628+
* @param options update options
629+
* @return WorkflowUpdateHandle that can be used to get the result of the update
630+
*/
631+
static <A1, A2, A3> WorkflowUpdateHandle<Void> startUpdate(
632+
Functions.Proc3<A1, A2, A3> updateMethod,
633+
A1 arg1,
634+
A2 arg2,
635+
A3 arg3,
636+
@Nonnull UpdateOptions<Void> options) {
637+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, arg3, options);
638+
}
639+
640+
/**
641+
* Start a four argument workflow update with a void return type
642+
*
643+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
644+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
645+
* @param arg1 first update method parameter
646+
* @param arg2 second update method parameter
647+
* @param arg3 third update method parameter
648+
* @param arg4 fourth update method parameter
649+
* @param options update options
650+
* @return WorkflowUpdateHandle that can be used to get the result of the update
651+
*/
652+
static <A1, A2, A3, A4> WorkflowUpdateHandle<Void> startUpdate(
653+
Functions.Proc4<A1, A2, A3, A4> updateMethod,
654+
A1 arg1,
655+
A2 arg2,
656+
A3 arg3,
657+
A4 arg4,
658+
@Nonnull UpdateOptions<Void> options) {
659+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, arg3, arg4, options);
660+
}
661+
662+
/**
663+
* Start a five argument workflow update with a void return type
664+
*
665+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
666+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
667+
* @param arg1 first update method parameter
668+
* @param arg2 second update method parameter
669+
* @param arg3 third update method parameter
670+
* @param arg4 fourth update method parameter
671+
* @param arg5 fifth update method parameter
672+
* @param options update options
673+
* @return WorkflowUpdateHandle that can be used to get the result of the update
674+
*/
675+
static <A1, A2, A3, A4, A5> WorkflowUpdateHandle<Void> startUpdate(
676+
Functions.Proc5<A1, A2, A3, A4, A5> updateMethod,
677+
A1 arg1,
678+
A2 arg2,
679+
A3 arg3,
680+
A4 arg4,
681+
A5 arg5,
682+
@Nonnull UpdateOptions<Void> options) {
683+
return WorkflowClientInternalImpl.startUpdate(
684+
updateMethod, arg1, arg2, arg3, arg4, arg5, options);
685+
}
686+
687+
/**
688+
* Start a six argument workflow update with a void return type
689+
*
690+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
691+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
692+
* @param arg1 first update method parameter
693+
* @param arg2 second update method parameter
694+
* @param arg3 third update method parameter
695+
* @param arg4 fourth update method parameter
696+
* @param arg5 fifth update method parameter
697+
* @param arg6 sixth update method parameter
698+
* @param options update options
699+
* @return WorkflowUpdateHandle that can be used to get the result of the update
700+
*/
701+
static <A1, A2, A3, A4, A5, A6> WorkflowUpdateHandle<Void> startUpdate(
702+
Functions.Proc6<A1, A2, A3, A4, A5, A6> updateMethod,
703+
A1 arg1,
704+
A2 arg2,
705+
A3 arg3,
706+
A4 arg4,
707+
A5 arg5,
708+
A6 arg6,
709+
@Nonnull UpdateOptions<Void> options) {
710+
return WorkflowClientInternalImpl.startUpdate(
711+
updateMethod, arg1, arg2, arg3, arg4, arg5, arg6, options);
712+
}
713+
714+
/**
715+
* Start a zero argument update workflow request asynchronously.
716+
*
717+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
718+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
719+
* @param options update options
720+
* @return WorkflowUpdateHandle that can be used to get the result of the update
721+
*/
722+
@Experimental
723+
static <R> WorkflowUpdateHandle<R> startUpdate(
724+
Functions.Func<R> updateMethod, @Nonnull UpdateOptions<R> options) {
725+
return WorkflowClientInternalImpl.startUpdate(updateMethod, options);
726+
}
727+
728+
/**
729+
* Start a one argument update workflow request asynchronously.
730+
*
731+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
732+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
733+
* @param arg1 first update method parameter
734+
* @param options update options
735+
* @return WorkflowUpdateHandle that can be used to get the result of the update
736+
*/
737+
@Experimental
738+
static <R, A1> WorkflowUpdateHandle<R> startUpdate(
739+
Functions.Func1<A1, R> updateMethod, A1 arg1, @Nonnull UpdateOptions<R> options) {
740+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, options);
741+
}
742+
743+
/**
744+
* Start a two argument update workflow request asynchronously.
745+
*
746+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
747+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
748+
* @param arg1 first update method parameter
749+
* @param arg2 second update method parameter
750+
* @param options update options
751+
* @return WorkflowUpdateHandle that can be used to get the result of the update
752+
*/
753+
@Experimental
754+
static <R, A1, A2> WorkflowUpdateHandle<R> startUpdate(
755+
Functions.Func2<A1, A2, R> updateMethod,
756+
A1 arg1,
757+
A2 arg2,
758+
@Nonnull UpdateOptions<R> options) {
759+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, options);
760+
}
761+
762+
/**
763+
* Start a three argument update workflow request asynchronously.
764+
*
765+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
766+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
767+
* @param arg1 first update method parameter
768+
* @param arg2 second update method parameter
769+
* @param arg3 third update method parameter
770+
* @param options update options
771+
* @return WorkflowUpdateHandle that can be used to get the result of the update
772+
*/
773+
@Experimental
774+
static <R, A1, A2, A3> WorkflowUpdateHandle<R> startUpdate(
775+
Functions.Func3<A1, A2, A3, R> updateMethod,
776+
A1 arg1,
777+
A2 arg2,
778+
A3 arg3,
779+
@Nonnull UpdateOptions<R> options) {
780+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, arg3, options);
781+
}
782+
783+
/**
784+
* Start a four argument update workflow request asynchronously.
785+
*
786+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
787+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
788+
* @param arg1 first update method parameter
789+
* @param arg2 second update method parameter
790+
* @param arg3 third update method parameter
791+
* @param arg4 fourth update method parameter
792+
* @param options update options
793+
* @return WorkflowUpdateHandle that can be used to get the result of the update
794+
*/
795+
@Experimental
796+
static <R, A1, A2, A3, A4> WorkflowUpdateHandle<R> startUpdate(
797+
Functions.Func4<A1, A2, A3, A4, R> updateMethod,
798+
A1 arg1,
799+
A2 arg2,
800+
A3 arg3,
801+
A4 arg4,
802+
@Nonnull UpdateOptions<R> options) {
803+
return WorkflowClientInternalImpl.startUpdate(updateMethod, arg1, arg2, arg3, arg4, options);
804+
}
805+
806+
/**
807+
* Start a five argument update workflow request asynchronously.
808+
*
809+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
810+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
811+
* @param arg1 first update method parameter
812+
* @param arg2 second update method parameter
813+
* @param arg3 third update method parameter
814+
* @param arg4 fourth update method parameter
815+
* @param arg5 firth update method parameter
816+
* @param options update options
817+
* @return WorkflowUpdateHandle that can be used to get the result of the update
818+
*/
819+
@Experimental
820+
static <R, A1, A2, A3, A4, A5> WorkflowUpdateHandle<R> startUpdate(
821+
Functions.Func5<A1, A2, A3, A4, A5, R> updateMethod,
822+
A1 arg1,
823+
A2 arg2,
824+
A3 arg3,
825+
A4 arg4,
826+
A5 arg5,
827+
@Nonnull UpdateOptions<R> options) {
828+
return WorkflowClientInternalImpl.startUpdate(
829+
updateMethod, arg1, arg2, arg3, arg4, arg5, options);
830+
}
831+
832+
/**
833+
* Start a six argument update workflow request asynchronously.
834+
*
835+
* @param updateMethod method reference annotated with @UpdateMethod of a proxy created through
836+
* {@link WorkflowClient#newWorkflowStub(Class, WorkflowOptions)}.
837+
* @param arg1 first update method parameter
838+
* @param arg2 second update method parameter
839+
* @param arg3 third update method parameter
840+
* @param arg4 fourth update method parameter
841+
* @param arg5 firth update method parameter
842+
* @param arg6 sixth update method parameter
843+
* @param options update options
844+
* @return WorkflowUpdateHandle that can be used to get the result of the update
845+
*/
846+
@Experimental
847+
static <R, A1, A2, A3, A4, A5, A6> WorkflowUpdateHandle<R> startUpdate(
848+
Functions.Func6<A1, A2, A3, A4, A5, A6, R> updateMethod,
849+
A1 arg1,
850+
A2 arg2,
851+
A3 arg3,
852+
A4 arg4,
853+
A5 arg5,
854+
A6 arg6,
855+
@Nonnull UpdateOptions<R> options) {
856+
return WorkflowClientInternalImpl.startUpdate(
857+
updateMethod, arg1, arg2, arg3, arg4, arg5, arg6, options);
858+
}
859+
575860
/**
576861
* Executes zero argument workflow with void return type together with an update workflow request.
577862
*

0 commit comments

Comments
 (0)