Skip to content

Commit

Permalink
Add some intro and make Query snippet more self-contained
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Aug 14, 2024
1 parent bb60ed2 commit ccf39ea
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/develop/python/message-passing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ tags:
- dynamic-handlers
---

A Workflow can be thought of as a stateful web service that can receive messages: Queries, Signals, and Updates.
Clients can use these to read data from a Workflow and control its execution.
See [Workflow message passing](/encyclopedia/workflow-message-passing) for a non–Python-specific
introduction to using messages with Temporal Workflows.
introduction.

## Writing message handlers

Expand Down Expand Up @@ -57,7 +59,12 @@ class GetLanguagesInput:

@workflow.defn
class GreetingWorkflow:
...
def __init__(self) -> None:
self.greetings = {
Language.CHINESE: "你好,世界",
Language.ENGLISH: "Hello, world",
}

@workflow.query
def get_languages(self, input: GetLanguagesInput) -> list[Language]:
# 👉 A Query handler returns a value: it can inspect but must not mutate the Workflow state.
Expand Down

0 comments on commit ccf39ea

Please sign in to comment.