Skip to content

Commit 972bc96

Browse files
authored
Update docs for workflow context (#29)
Update docs based on our latest changes in dbos-inc/dbos-transact-ts#149, where we added `getEvent()` and `retrieveWorkflow()` methods in workflow context. Question: should we merge this into main, or do we want to create a branch for the next release?
1 parent 4eb302f commit 972bc96

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

.github/workflows/deploy.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: Deploy to GitHub Pages
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
# push: ### Temporarily disable auto deployment on push to main.
5+
# branches:
6+
# - main
77
# Review gh actions docs if you want to further define triggers, paths, etc
88
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
9+
workflow_dispatch:
910

1011
jobs:
1112
deploy:

.github/workflows/test-deploy.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Test deployment
22

33
on:
4+
push: ### Temporarily enable test on main.
5+
branches:
6+
- main
47
pull_request:
58
branches:
69
- main

docs/api-reference/contexts.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ getEvent<T extends NonNullable<any>>(workflowUUID: string, key: string, timeoutS
198198
```
199199
200200
Retrieves an event published by _workflowUUID_ for a given key using the [events API](../tutorials/workflow-communication-tutorial#events-api).
201-
A call to `getEvent` waits for the workflow to publish the key, returning `null` if the wait times out:
201+
Awaiting on the promise returned by `getEvent()` waits for the workflow to publish the key, returning `null` if the wait times out.
202202
203203
---
204204
@@ -213,6 +213,8 @@ Workflows use `WorkflowContext` to invoke other functions and interact with othe
213213
- [send(destinationUUID, message, \[topic\])](#workflowctxtsenddestinationuuid-message-topic)
214214
- [recv(\[topic, timeoutSeconds\])](#workflowctxtrecvtopic-timeoutseconds)
215215
- [setEvent(key, value)](#workflowctxtseteventkey-value)
216+
- [getEvent()](#workflowctxtgeteventworkflowuuid-key-timeoutseconds)
217+
- [retrieveWorkflow(workflowUUID)](#workflowctxtretrieveworkflowworkflowuuid)
216218
217219
### workflowCtxt.invoke(targetClass)
218220
@@ -279,6 +281,25 @@ HTTP handlers can read events by calling [`getEvent`](#handlerctxtgeteventworkfl
279281
Events are immutable and attempting to emit an event twice from a given workflow instance will result in an error.
280282
For more information, see our [events API tutorial](../tutorials/workflow-communication-tutorial#events-api).
281283
284+
### workflowCtxt.getEvent(workflowUUID, key, \[timeoutSeconds\])
285+
286+
```typescript
287+
getEvent<T extends NonNullable<any>>(workflowUUID: string, key: string, timeoutSeconds?: number): Promise<T | null>
288+
```
289+
290+
Retrieves an event published by _workflowUUID_ for a given key using the [events API](../tutorials/workflow-communication-tutorial#events-api).
291+
Awaiting on the promise returned by `getEvent()` waits for the workflow to publish the key, returning `null` if the wait times out.
292+
293+
### workflowCtxt.retrieveWorkflow(workflowUUID)
294+
295+
```typescript
296+
retrieveWorkflow<R>(workflowUUID: string): WorkflowHandle<R>
297+
```
298+
299+
Returns a [workflow handle](./workflow-handles.md) to the workflow with [identity](../tutorials/workflow-tutorial#workflow-identity) _workflowUUID_.
300+
`R` is the return type of the target workflow.
301+
302+
282303
---
283304
284305
## `TransactionContext<T>`

0 commit comments

Comments
 (0)