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

Deprecate NewClient, add Dial and NewLazyClient and CheckHealth #795

Merged
merged 5 commits into from
May 6, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Apr 28, 2022

What was changed

Mostly what's at #793 w/ slight changes.

  • Add client.Dial which eagerly connects like NewClient does
  • Add client.NewLazyClient which doesn't connect until you make a call
  • Deprecate NewClient
  • Make sure server capabilities are lazily fetched before each high-level call and before worker start if they are not already fetched
  • Add client.Client.CheckHealth call

Why?

People want lazy-connecting clients but we still need capabilities checks. People also wanted explicit health checking.

Checklist

  1. Closes Deprecate NewClient, create Dial, NewLazyClient, and CheckHealth calls and support laziness #793
  2. Closes Allow lazy connection on client #753
  3. Closes Expose health check on WorkflowClient #595

internal/client.go Outdated Show resolved Hide resolved
@cretz cretz changed the title Lazy client and health check call Deprecate NewClient, add Dial and NewLazyClient and CheckHealth Apr 29, 2022
@cretz cretz changed the title Deprecate NewClient, add Dial and NewLazyClient and CheckHealth Deprecate NewClient, add Dial and NewLazyClient and CheckHealth Apr 29, 2022
Comment on lines +205 to +207
// We intentionally don't "ensureIntialized" here because there is no direct
// error return path. Rather we let GetWorkflowHistory do it.

Copy link
Member

Choose a reason for hiding this comment

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

I'd avoid words "we" and "I" in comments. Something more "dry" is better here:

Suggested change
// We intentionally don't "ensureIntialized" here because there is no direct
// error return path. Rather we let GetWorkflowHistory do it.
// "ensureIntialized" is not called here intentionally because there is no direct
// error return path. GetWorkflowHistory will do it.

// to the server eagerly and will return an error if the server is not
// available.
func Dial(options Options) (Client, error) {
return internal.DialClient(options)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return internal.DialClient(options)
return internal.Dial(options)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just Dial in a client package makes sense, but just Dial in an internal package where you could be dialing other things does not. worker.New -> internal.NewWorker, client.Options -> internal.ClientOptions, etc, etc.

Copy link
Contributor

@mmcshane mmcshane left a comment

Choose a reason for hiding this comment

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

I'm okay with it because the functionality is there but I had different expectations.

I had understood that all SDKs would move to become lazy by default with an option to be eager and thus I expected Dial to be lazy and NewClient to remain eager (to be kind to existing callers who might expect certain behavior). Not sure that NewLazyClient pulls its own weight in terms of utility versus adding to the API surface area.

// Dial creates an instance of a workflow client. This will attempt to connect
// to the server eagerly and will return an error if the server is not
// available.
func Dial(options Options) (Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curous if you considered taking this opportunity to move to function-style optional args?

Copy link
Member Author

Choose a reason for hiding this comment

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

For most of the Go SDK, the struct options is good enough to still give us future proofing. There's little benefit of a func Dial(options ...DialOption) (Client, error) over struct-based if you 1) have no other params, 2) don't need to preserve backwards compatibility, and 3) can reasonably copy the struct.

I could be leaving off an important benefit, so if there is a good enough argument I'd definitely reconsider.

@cretz cretz merged commit ee5ae6f into temporalio:master May 6, 2022
@cretz cretz deleted the lazy-client-and-health branch May 6, 2022 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants