Skip to content

Conversation

@cretz
Copy link
Member

@cretz cretz commented Jan 24, 2025

What was changed

  • Added Temporalio::Activity::Context#instance to access the activity instance
  • Added Temporalio::Workflow.instance to access the workflow instance

Checklist

  1. Closes [Feature Request] Access to workflow/activity instance from context #180

@cretz cretz requested a review from a team January 24, 2025 21:12
Comment on lines +241 to +242
# Create the instance. We choose to do this before interceptors so that it is available in the interceptor.
activity.instance = defn.instance.is_a?(Proc) ? defn.instance.call : defn.instance # steep:ignore
Copy link
Member

Choose a reason for hiding this comment

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

Could've done this by ensuring the first interceptor is always an interceptor that makes the instance

😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Not following this exactly. We originally had our interceptor make the instance, but that didn't provide the instance early enough for user interceptors. We don't have control over interceptor order to ensure any one is the first.

@cretz cretz merged commit 2115ff7 into temporalio:main Jan 27, 2025
6 checks passed
@cretz cretz deleted the context-instance branch January 27, 2025 15:11
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

2 participants