sdk-java icon indicating copy to clipboard operation
sdk-java copied to clipboard

Provide ActivityStub that is bound to the specific activityType or a specific invocation

Open Spikhalskiy opened this issue 3 years ago • 0 comments

Temporal JavaSDK has an untyped WorkflowStub that is bound to a specific method invocation (workflow method), while a currently existing ActivityStub is bound to the AcitivityInterface and not to the specific activity type.

The source of the inconsistency is that one WorkflowInterface has always only one "entry" workflow method, while an ActivityInterface can have several ActivityMethod.

To keep things consistent, we should have a variation of the ActivityStub that binds an execution of the activity to a specific type the same way as WorkflowStub. There also should be an ActivityStub.fromTyped method working similarly with WorkflowStub.fromTyped (but probably taking a method reference instead of a pointer to an instance)

The current Activity stub that we have in JavaSDK looks like

public interface ActivityStub {
  <R> R execute(String activityName, Class<R> resultClass, Object... args);

  <R> R execute(String activityName, Class<R> resultClass, Type resultType, Object... args);

  <R> Promise<R> executeAsync(String activityName, Class<R> resultClass, Object... args);

  <R> Promise<R> executeAsync(
      String activityName, Class<R> resultClass, Type resultType, Object... args);
}```
which is inconsistent with WorkflowStub and makes it harder to work with untyped ActivityStubs.

Spikhalskiy avatar Jan 29 '22 21:01 Spikhalskiy