Standalone Activities for Java#2858
Conversation
Remove isEmpty() check from isWorkflowActivity.
This reverts commit 381e66c.
…h listActivities and listActivitiesPaginated in the interceptor
…ry and the client's rpc boundary (this and previous)
| @@ -25,7 +25,7 @@ protected ActivityCompletionException(ActivityInfo info, Throwable cause) { | |||
| ? "WorkflowId=" | |||
| + info.getWorkflowId() | |||
| + ", RunId=" | |||
There was a problem hiding this comment.
I wonder if we should change the property name. Any down side to doing that?
| + ", RunId=" | |
| + ", WorkflowRunId=" |
If we do that, there are likely other places where should do the same.
There was a problem hiding this comment.
Will do in a followup PR.
| return "ActivityInfo{" | ||
| + "workflowId=" | ||
| + getWorkflowId() | ||
| + ", runId=" |
There was a problem hiding this comment.
We should no longer be using getRunId here. Either workflowRunId or activityRunId.
There was a problem hiding this comment.
Will do in a followup PR.
| * to reduce the total execution time. | ||
| */ | ||
| public class GetActivityResultAsyncOverServerLongPollWaitTest { | ||
| private static final int ACTIVITY_LONG_POLL_TIMEOUT_SECONDS = 20; |
There was a problem hiding this comment.
Where does this "20 sec" come from?
There was a problem hiding this comment.
It's the server-side long poll time; see also GetResultsAsyncOverMaximumLongPollWaitTest.
These tests could be made more robust by checking that the retry count is at least two, but that would require more machinery in the test so I'm not sure it's a good idea.
…edundant Impl implementations.
maciejdudko
left a comment
There was a problem hiding this comment.
Looks good, but there are a couple things that need to be fixed before merging, most notably caching inside ActivityHandleImpl and how AsyncCompletionClient creates ManualActivityCompletionClient for standalone activities. See comments in code.
| private ActivityExecutionInfo info() { | ||
| return info; | ||
| } |
There was a problem hiding this comment.
This method is unnecessary.
There was a problem hiding this comment.
This test suite does not meaningfully test anything in real implementation. Instead, the tests should create ActivityClient with 2 interceptors and verify that they are being called in order when the client method is called.
There was a problem hiding this comment.
Nit: personal taste, but I would rename this suite to ActivityInfoImplTest.
| } | ||
|
|
||
| @Test | ||
| public void testDescribeNoToken() { |
There was a problem hiding this comment.
Since we don't support long poll describe, rename to testDescribe.
| client.start(SimpleActivity.class, SimpleActivity::execute, simpleOpts(activityId), "test"); | ||
| assertEquals("echo:test", handle.getResult()); | ||
|
|
||
| UntypedActivityHandle handle2 = client.getHandle(activityId, handle.getActivityRunId()); |
There was a problem hiding this comment.
We should have a test for getHandle with null run ID.
| @Test | ||
| public void testExecuteActivityVoidResult() { | ||
| assumeTrue(SDKTestWorkflowRule.useExternalService); | ||
| newActivityClient().execute(VoidActivity.class, VoidActivity::execute, simpleOpts(uniqueId())); | ||
| } |
There was a problem hiding this comment.
We should have a test that checks if the void execute overload properly discards result of non-void activity.
Implemented this by adding a Deadline to RootActivityClientInvoker.getActivityResult. Also: In tests, use .start(...).get() instead of .executeAsync, for clarity. Added stopwatch check to testGetActivityResultAsyncTimeoutAbortsPolling to avoid possibility of false negative.
Add standalone activity API (ActivityClient)
Introduces support for standalone activities — activities that execute independently of any workflow.
New public API surface:
ActivityClient— top-level client for starting, describing,listing, counting, cancelling, and terminating standalone activities
ActivityHandle<R>/UntypedActivityHandle— typed and untypedhandles returned by
ActivityClient.start(); providegetResult(),getResultAsync(),describe(),cancel(), andterminate()StartActivityOptions— builder-based options for starting anactivity (id, task queue, timeouts, retry, priority, etc.)
ActivityClientOptions— namespace / data converter / interceptorconfiguration for
ActivityClientActivityExecutionDescription— rich descriptor returned bydescribe()andlist*(); extendsActivityExecutionMetadataActivityExecutionMetadata— lightweight metadata used in listresults
ActivityExecutionCount— result ofcountActivities()ActivityListOptions/ActivityListPaginatedOptions— filteringand pagination options for list operations
ActivityListPage— page of results with continuation tokenActivityAlreadyStartedException— thrown when a duplicate activityid is rejected by the server
ActivityFailedException— thrown fromgetResult()when theactivity fails
New interceptor API:
ActivityClientCallsInterceptor— per-call interceptor for allActivityClientoperationsActivityClientCallsInterceptorBase— pass-through baseimplementation (delegates every method to the next interceptor)
ActivityClientInterceptor— factory interceptor that wraps theclient-level invoker
ActivityClientInterceptorBase— no-op base implementationActivityInfoadditions:getActivityRunId()— run-scoped id assigned by the server to eachactivity execution
isWorkflowActivity()— distinguishes workflow-dispatched activitiesfrom standalone ones
ActivityCompletionClientadditions:(String activityId, Optional<String> runId, …)for completing, failing, sending heartbeats, and cancelling standalone
activities without a workflow id
ActivitySerializationContextfix:workflowIdandworkflowTypeare now@Nullable; removedrequireNonNullguards that caused NPEs for standalone activitiesFunctions.java:FuncandVFunc(zero-arg typed/void functional interfaces)needed by
ActivityClient.start()method-reference overloadsCI:
dev server used by unit tests:
frontend.activityAPIsEnabled,activity.enableStandalone,history.enableChasm,history.enableTransitionHistoryTests:
StandaloneActivityTest— integration tests against a real servercovering the full activity lifecycle (start, poll, complete, cancel,
terminate, describe, list, heartbeat, async completion)
ActivityClientCallsInterceptorBaseTest— delegation tests for thebase interceptor
ActivityClientCallsInterceptorChainTest— chain ordering testsActivityHandleImplTest— unit tests for handle dispatchActivityCompletionClientImplTest— unit tests for completion clientActivityInfoStandaloneTest— unit tests forActivityInfoin thestandalone context
ActivitySerializationContextTest— confirms nullable workflow fieldsStartActivityOptionsTest,ActivityClientOptionsTest,ActivityExecutionDescriptionTest,ActivityExecutionMetadataTest,ActivityAlreadyStartedExceptionTest— options and value-type tests