Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushisource committed Oct 20, 2023
1 parent 2e54df6 commit 188bf97
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ Some things to note about the above code:
#### Definition

Workflows are defined as classes decorated with `@workflow.defn`. The method invoked for the workflow is decorated with
`@workflow.run`. Methods for signals and queries are decorated with `@workflow.signal` and `@workflow.query`
respectively. Here's an example of a workflow:
`@workflow.run`. Methods for signals, queries, and updates are decorated with `@workflow.signal`, `@workflow.query`
and `@workflow.update` respectively. Here's an example of a workflow:

```python
import asyncio
Expand Down Expand Up @@ -515,6 +515,12 @@ class GreetingWorkflow:
@workflow.query
def current_greeting(self) -> str:
return self._current_greeting

@workflow.update
def set_and_get_greeting(self, greeting: str) -> str:
old = self._current_greeting
self._current_greeting = greeting
return old

```

Expand Down Expand Up @@ -582,6 +588,14 @@ Here are the decorators that can be applied:
* All the same constraints as `@workflow.signal` but should return a value
* Should not be `async`
* Temporal queries should never mutate anything in the workflow or call any calls that would mutate the workflow
* `@workflow.update` - Defines a method as an update
* May both accept as input and return a value
* May be `async` or non-`async`
* May mutate workflow state, and make calls to other workflow APIs like starting activities, etc.
* Also accepts the `name` and `dynamic` parameters like signals and queries, with the same semantics.
* Update handlers may optionally define a validator method by decorating it with `@update_handler_method.validator`.
Validators cannot be `async`, cannot mutate workflow state, and return nothing. They can be used to reject update
calls before any events are written to history by throwing an exception.

#### Running

Expand Down

0 comments on commit 188bf97

Please sign in to comment.