Skip to content

Expose Activity and Workflow instance from context #593

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

roxblnfk
Copy link
Collaborator

@roxblnfk roxblnfk commented Apr 11, 2025

What was changed

  • Added Activity::getInstance() and Workflow::getInstance()
  • Changed workflow execution flow:
    • First, the Workflow is initialized.
      • It is recommended not to make calls to start Activity, ChildWorkflow, Timer, etc.
      • If the #[WorkflowInit] attribute is present, the arguments are resolved.
    • WorkflowInboundCallInterceptor::execute() is called
      • Arguments from the previous step are used, but they can be overridden.
    • Workflow Handler is called.
  • Now errors from WorkflowInboundCallInterceptor::execute() are recorded in the Workflow history.

Tests:

  • Acceptance Tests: added ability to customize workers per TaskQueue in tests.
  • Added tests for workflow dynamic handlers.

Why?

Checklist

  1. Closes [Feature Request] Access to workflow/activity instance from context #546
  2. How was this tested: added tests
  3. Any docs updates needed?

Copy link

vercel bot commented Apr 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
php ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2025 8:07am

@roxblnfk roxblnfk marked this pull request as ready for review April 17, 2025 11:54
@roxblnfk roxblnfk requested review from Sushisource and wolfy-j April 17, 2025 11:57
Comment on lines +188 to +190
// Initialize workflow instance
//
// Resolve arguments if #[WorkflowInit] is used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we do in the other SDKs is we actually run the init method in a special "readonly" context that will throw errors if the user attempts to issue any commands during init. I dunno if that's something that you can readily enforce, but if possible it's a nice bit of safety.

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.

[Feature Request] Access to workflow/activity instance from context
3 participants