-
Notifications
You must be signed in to change notification settings - Fork 220
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,6 +264,13 @@ func RecordActivityHeartbeat(ctx context.Context, details ...interface{}) { | |
getActivityOutboundInterceptor(ctx).RecordHeartbeat(ctx, details...) | ||
} | ||
|
||
// GetClient returns a client that can be used to interact with the Temporal | ||
// service from an activity. | ||
func GetClient(ctx context.Context) Client { | ||
activityEnv := getActivityEnv(ctx) | ||
return activityEnv.serviceInvoker.GetClient(ClientOptions{Namespace: activityEnv.workflowNamespace}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
// ServiceInvoker abstracts calls to the Temporal service from an activity implementation. | ||
// Implement to unit test activities. | ||
type ServiceInvoker interface { | ||
|
There was a problem hiding this comment.
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 theactivity
package. Maybe that's ok? I wonder if it'd be ok to just do just haveGetClient
returninternal.Client
instead. Thoughts?