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

Expose workflow client from Activity #1783

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

Conversation

yuandrew
Copy link
Contributor

What was changed

Added a new GetClient function in the activity package

Why?

Allow users to access Temporal client from within an activity

Checklist

  1. Closes Provide client from activity context #1761

  2. How was this tested:
    Add unit and integration test

  3. Any docs updates needed?

@yuandrew yuandrew requested a review from a team as a code owner January 17, 2025 20:22
// service from an activity.
func GetClient(ctx context.Context) Client {
activityEnv := getActivityEnv(ctx)
return activityEnv.serviceInvoker.GetClient(ClientOptions{Namespace: activityEnv.workflowNamespace})
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, but you are not using the client , or client options the worker was started with. So if the worker client was configured with a data converter or interceptor I don't think this client will have it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you might need to just wire the client from worker constructor down to here.

@@ -26,7 +26,7 @@ package activity

import (
"context"

"go.temporal.io/sdk/client"
Copy link
Member

Choose a reason for hiding this comment

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

I am slightly concerned about this package dependency. We now will never be able to have any package that client depends on depend on the activity package. Maybe that's ok? I wonder if it'd be ok to just do just have GetClient return internal.Client instead. Thoughts?

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.

Provide client from activity context
3 participants