Improved orchestrator and activity input/output handling
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- backend-api-design
Research direction
Start by reviewing the TaskOrchestration and TaskActivity interfaces and the integration-test examples referenced in the issue. Trace how inputs and outputs currently flow through the context, then update the programming model so implementations receive typed inputs and return outputs as shown; the integration tests should demonstrate the proposed usage.
Written by the indexing model from the issue text.
Description
Background
The current TaskOrchestration and TaskActivity interfaces require implementations to use the context object to receive inputs. Consider the following example (copied from the integration tests):
final String orchestratorName = "SingleActivity";
final String activityName = "Echo";
final String input = Instant.now().toString();
DurableTaskGrpcWorker worker = this.createWorkerBuilder()
.addOrchestrator(orchestratorName, ctx -> {
String activityInput = ctx.getInput(String.class);
String output = ctx.callActivity(activityName, activityInput, String.class).get();
ctx.complete(output);
})
.addActivity(activityName, ctx -> {
return String.format("Hello, %s!", ctx.getInput(String.class));
})
.buildAndStart();
This design, while it works, has a few issues:
- The fetching of inputs is not type-safe because the call to
ctx.getInput(String.class)could fail if the input isn't actually a string. - The call to
ctx.getInput()isn't intuitive, making the programming model harder for developers to learn. - The call to
ctx.complete(output)is both unintuitive and inconsistent with how activity functions are defined.
This issue tracks improving the programming model to make processing inputs and outputs more intuitive and type-safe.
Proposal
The proposal is to change these interface definitions so that a developer could write the following, simpler orchestration and activity implementations:
final String orchestratorName = "SingleActivity";
final String activityName = "Echo";
final String input = Instant.now().toString();
DurableTaskGrpcWorker worker = this.createWorkerBuilder()
.addOrchestrator(orchestratorName, (ctx, activityInput) -> {
return ctx.callActivity(activityName, activityInput, String.class).get();
})
.addActivity(activityName, (ctx, name) -> {
return String.format("Hello, %s!", name);
})
.buildAndStart();
The differences are:
- The orchestrator and activity functions have the input passed to them explicitly.
- The orchestrator can use the return value to set the output.
This results in a simpler, more intuitive programming model and is also consistent with the proposed C# programming model.
- Dominant language
- Java
- Stars
- 29
- Forks
- 18
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/durabletask-java
-
Needs: Triage :mag:
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/durabletask-java#303 ·
-
Needs: Triage :mag:
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/durabletask-java#290 · 2 comments ·
-
Needs: Triage :mag:
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/durabletask-java#285 ·
-
Needs: Triage :mag:
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/durabletask-java#276 ·
-
Enhancement
microsoft/durabletask-java#274 · 1 reaction · 2 assignees ·
All issues in microsoft/durabletask-java
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100