Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Request/Response sample with activity-based responses (fixes #6) #166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

barmoshe
Copy link

What was changed

  • Added a new sample directory reqrespactivity to the repository.
  • Ported the Request/Response demo from Go to Python, which demonstrates how to send a request (via a signal) to a workflow and receive a response via a callback activity.
  • This sample includes:
    • workflow.py: Contains the workflow definition, data models, and the uppercase activity.
    • requester.py: Implements a requester that signals the workflow and awaits the callback response.
    • starter.py: Starts the workflow.
    • worker.py: Runs the workflow and activity worker.
    • requester_run.py: Continuously sends requests (e.g., "foo0", "foo1", etc.) to the workflow and prints the uppercase responses.
  • An updated README (README.md) provides detailed instructions on running the sample.

Why?

  • To provide a Python port of the Request/Response demo as seen in the Go samples.
  • This sample demonstrates the use of Temporal's Python SDK for activity-based responses where the workflow processes signal-based requests and responds using a callback activity.
  • The implementation serves as a reference for users looking to integrate similar functionality in their Python applications.

Checklist

  1. Closes #6 and #7
  2. How was this tested:
    • A Temporal server was run locally using Docker.
    • The worker was started via python worker.py to register the workflow and activity.
    • The workflow was started using python starter.py and confirmed to be running.
    • The requester was executed using python requester_run.py, which sent requests (e.g., "foo0", "foo1", etc.) and received correct uppercase responses ("FOO0", "FOO1", etc.).
  3. Any docs updates needed?
    • The new sample includes its own README that documents the sample and mirrors the instructions from the Go version.
    • No further updates to docs.temporal.io are required at this time.

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2025

CLA assistant check
All committers have signed the CLA.

@cretz
Copy link
Member

cretz commented Mar 11, 2025

#6 and the Go samples predate Workflow Update. We now recommend using workflow update for request/response instead of the "response activity" pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sample request: Request/response
3 participants