-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support context #8
Comments
Since you're dealing with generated code I don't think the breaking change is much of an issue. gofix is the way to go 👍 translate Also I +💯 the initiative, we need contexts everywhere! |
I would suggest having 2 methods, one without the context support context != context or nothing ;) |
I actually prefer having one generated Go function per RPC method If we're even OK with enforcing client support for contexts, what should the interface of the client we ask the user for look like? type Client interface {
Call(method string, args interface{}, reply interface{}) error
} Right now, it's like so but not sure if the client template - https://github.com/segmentio/glue/blob/master/templates/client.gohtml |
If we have a decently big installed client base, we should be careful about breaking compatibility. Given that we're generating code, we can generate a new client that has an interface which supports contexts. How does the standard lib handle reporting back infrastructure-layer information (e.g. metrics or on-the-wire message sizes) without using a context ? |
Wild idea but since you have a code generator, you could make it generate either version. Add a command line argument to enable one version or the other. I doubt that there would be code out there that need both version of the methods in the same project. |
@gesterhuizen The standard library comes with a very bare RPC server and doesn't handle that. |
@achille-roussel Most of our services commit a |
But the caller could regenerate its own client if it didn't want context support right? Passing |
Just FYI, since the standard It extends
and client wrapper functions also take additional
|
Even though the standard library's
net/rpc
doesn't support contexts, we should because they're getting more popular and others have asked for it. The big question is-- Should we have aContext
suffixed method for every RPC endpoint, or should we make a breaking change and havecontext.Context
as the first argument across the board?I don't feel strongly. It's easy to add
context.TODO()
if you don't care about contexts in your caller, but I also don't want to trouble people too much by making a breaking change... though it may be a good opportunity for me (and others) to learn gofix.(Added assignees for feedback)
The text was updated successfully, but these errors were encountered: