-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement DialURLContext(...) #574
Conversation
and convert DialURL to call DialURLContext()
Hey @stevenh this is what I was thinking, although maybe there are reasons to pass the But it might confuse people. I have never seen a context.Context passed as an option like that, and the Google
And in my experience, the idiomatic Go way is to have a function named xxxContext when So, I might miss there is a way to pass a context.Context in if I didn't see But maybe it makes sense if the Dial method signatures are multiplying too much. |
Feels like we should change all Dialers to use ctx as the first arg in v2. I believe xxxContent function naming is due to the lack of context support in early go versions + v1 compatibility guarantee, so the original functions must be kept. Consistency vs other APIs which require ctx as first parameter is good point, it has the benefit that it enforces the design that a consumer should pass a valid context vs making less obvious with an additional functional option. |
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.
Thanks for the PR, I agree this is a better approach.
Lets get the docs for older none ctx Dial functions all updated to explicitly call out their wrap nature.
Please note this repo uses conventional commits.
Co-authored-by: Steven Hartland <steven.hartland@multiplay.co.uk>
Can you suggest/write the Conventional Commit labels? |
Sure It's really simple this is a feature so you would have something like this:
|
Add DialURLContext so that we can consumers have control over cancelation and timeout
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.
Thanks for the changes, just missing the suggested doc change for DialURL which makes it clear to the caller its a wrapper.
Comments on DialURL should reflect it is a wrapper around DialURLContext
@stevenh Thanks for taking this PR, and your patience while I got it into some type of passable shape. |
and convert DialURL to call DialURLContext()