-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signal/activities and rename interceptor feature (#354)
- Loading branch information
1 parent
cc11799
commit bad3e30
Showing
11 changed files
with
63 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Run activities from within a Workflow Signal | ||
|
||
Workflows can run activities from within a Signal handler. | ||
|
||
# Detailed spec | ||
|
||
Workflow Signal handlers are like workflow code in that they can invoke and wait on activities. | ||
This test invokes a number of activities within the Signal and blocks on them, returning from the Signal when they have all completed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Feature } from '@temporalio/harness'; | ||
import * as wf from '@temporalio/workflow'; | ||
import * as assert from 'assert'; | ||
|
||
const mySignal = wf.defineSignal<any[]>('mySignal'); | ||
const activityCount = 5; | ||
const activityResult = 6; | ||
|
||
const activitiesImpl = { | ||
async myActivity(): Promise<number> { | ||
return activityResult; | ||
}, | ||
}; | ||
|
||
const activities = wf.proxyActivities<typeof activitiesImpl>({ | ||
startToCloseTimeout: '5s', | ||
}); | ||
|
||
export const feature = new Feature({ | ||
workflow, | ||
activities: activitiesImpl, | ||
checkResult: async (_, handle) => { | ||
await handle.signal(mySignal); | ||
const result = await handle.result(); | ||
assert.equal(result, activityResult * activityCount); | ||
}, | ||
}); | ||
|
||
export async function workflow(): Promise<number> { | ||
let total = 0; | ||
wf.setHandler(mySignal, async () => { | ||
const promises = Array.from({ length: activityCount }, activities.myActivity); | ||
const counts = await Promise.all(promises); | ||
total = counts.reduce((a, b) => a + b, 0); | ||
}); | ||
await wf.condition(() => total > 0); | ||
return total; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
# Run activities from within a workflow update | ||
|
||
Workflows can run activities from within an update handler | ||
Workflows can run activities from within an update handler. | ||
|
||
# Detailed spec | ||
|
||
Workflow update handlers are like workflow code in that they can run for | ||
indefinitely long periods but must do so by invoking and waiting on activites. | ||
This test invokes a number of activities within the update and blocks on them, | ||
returning from the update when they have all completed. | ||
|
||
Workflow update handlers are like workflow code in that they can invoke and wait on activities. | ||
This test invokes a number of activities within the update and blocks on them, returning from the update when they have all completed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Update Calls Can Be Intercepted | ||
|
||
Client Interceptors can intercept and modify update requests | ||
|
||
# Detailed spec | ||
|
||
A client interceptor can be configured that modifies the arguments sent by a client to an Update handler. | ||
The modification is reflected in the Update response. |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
features/update/intercept/feature.java → ...es/update/client_interceptor/feature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters