@@ -458,8 +458,8 @@ Some things to note about the above code:
458458#### Definition
459459
460460Workflows are defined as classes decorated with ` @workflow.defn ` . The method invoked for the workflow is decorated with
461- ` @workflow.run ` . Methods for signals and queries are decorated with ` @workflow.signal ` and ` @workflow.query `
462- respectively. Here's an example of a workflow:
461+ ` @workflow.run ` . Methods for signals, queries, and updates are decorated with ` @workflow.signal ` , ` @workflow.query `
462+ and ` @workflow.update ` respectively. Here's an example of a workflow:
463463
464464``` python
465465import asyncio
@@ -515,6 +515,12 @@ class GreetingWorkflow:
515515 @workflow.query
516516 def current_greeting (self ) -> str :
517517 return self ._current_greeting
518+
519+ @workflow.update
520+ def set_and_get_greeting (self , greeting : str ) -> str :
521+ old = self ._current_greeting
522+ self ._current_greeting = greeting
523+ return old
518524
519525```
520526
@@ -582,6 +588,14 @@ Here are the decorators that can be applied:
582588 * All the same constraints as ` @workflow.signal ` but should return a value
583589 * Should not be ` async `
584590 * Temporal queries should never mutate anything in the workflow or call any calls that would mutate the workflow
591+ * ` @workflow.update ` - Defines a method as an update
592+ * May both accept as input and return a value
593+ * May be ` async ` or non-` async `
594+ * May mutate workflow state, and make calls to other workflow APIs like starting activities, etc.
595+ * Also accepts the ` name ` and ` dynamic ` parameters like signals and queries, with the same semantics.
596+ * Update handlers may optionally define a validator method by decorating it with ` @update_handler_method.validator ` .
597+ To reject an update before any events are written to history, throw an exception in a validator. Validators cannot
598+ be ` async ` , cannot mutate workflow state, and return nothing.
585599
586600#### Running
587601
@@ -1440,6 +1454,13 @@ to `1` prior to running tests.
14401454Do not commit ` poetry.lock ` or ` pyproject.toml ` changes. To go back from this downgrade, restore ` pyproject.toml ` and
14411455run ` poetry update protobuf grpcio-tools ` .
14421456
1457+ For a less system-intrusive approach, you can:
1458+ ``` shell
1459+ docker build -f scripts/_proto/Dockerfile .
1460+ docker run -v " ${PWD} /temporalio/api:/api_new" -v " ${PWD} /temporalio/bridge/proto:/bridge_new" < just built image sha>
1461+ poe format
1462+ ```
1463+
14431464### Style
14441465
14451466* Mostly [ Google Style Guide] ( https://google.github.io/styleguide/pyguide.html ) . Notable exceptions:
0 commit comments