-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add golang context support #153
Conversation
This is a large cross cutting change to the existing interfaces for go-gerrit that introduces context support to all interfaces drilling down to the HTTP level. Contexts enable support for both passing information through (eg: tracing, logging, etc) and features like cancellation of slow operations (eg: REST calls). In order for consumers of this breaking change to adapt their code to use the new interface they must add a context parameter to their invocations. In most cases this can just be `context.Background()`
@andygrunwald bump |
@kellyma2 Thanks a lot for this PR. The change itself is looking good. This change would be a breaking change in the library. This is an option, but I hope that all downstream users have go modules active. Before merging, I am highlighting a few folks that I know using this library to get their objections (because in the end, they need to make the change in their applications): @opalmer @dmitshur @banksean @chyroc @wwade @hanwen @lukegb @pastel001 @afq984 Any objections from your end? If there is no objections until Wednesday, 1st of November 2023, 8 am UTC, I will merge it. |
Obviously I have my personal opinions on merit, but I like the breaking change as it's a clear signal (and very easy to fix in consumer code). Alternatively, a versioned API could work, but this also represents a fork in the road. |
I don't run go-gerrit code myself, but know folks that do. I have a dissenting opinion. Merging this change will gratuitiously break users that might want to upgrade to get a bugfix or more Gerrit API coverage, without providing any upside. Why not add the
See also https://go.dev/blog/context-and-structs. |
@hanwen Looking at the size of the change, adding In the The third alternative (which I mentioned) is to do something like what was done with go-redis. They have a versioned API and for v8 they dropped the non-context versions and replaced them with the context-using versions. This has the same problem you're describing though. However, the breakage seems to have been ok in that case and I assume that go-redis has pretty broad usage. Fwiw, I'm ok with re-working this to be like either option (1) or option (3), but my gut feeling is that option (2) would be confusing for users of this library. edit: Should add that another option is to keep a branch with a pre-break release tag and just port bugfixes over if desired. Not sure how desirable that is for @andygrunwald but at least folks can get bugfixes if they want them? |
if users care about context, they should create a new one per context.
I doubt that someone needing to upgrade go-redis in a large company monorepo would have been amused with the move. |
In the
YMMV, but since the |
I'm saying this out of experience with google monorepo, where -due to its size- changing a wide swath of code is actually a lot of work. The Go team is extremely conservative with introducing incompatible changes, and I think it is a good example to follow.
I don't mind adding XxxWithContext(). I am arguing against removing the Xxx (without Full-disclosure: I don't work on Gerrit anymore, so I don't care very much which way this goes, but Andy asked my opinion, so I am giving it. |
Sorry, just wanted to clarify what I think you're suggesting here. It sounds like to me you're suggesting that (1) we add xxxWithContext() for existing methods, (2) we add both xxxWithContext() and xxx() for new methods? |
yes for (1). At your option (2) as well, but it's less important for backward compatibility. |
Just my two cents, assuming that we don't have breaking changes too often, I'd rather downstreams figure out a way to pay an one-off migration cost, instead of keeping the extra maintenance cost in the upstream (and duplicated API, docs for everyone) indefinitely, as I think it's much harder to get people to volunteer on open source work Especially since #153 (comment) indicates that the changes are mechanical and automatable. Well, maybe there's some way to allow downstreams to migrate call sites incrementally instead of all at once, then it'd be an easier breaking change to take on. But I don't have an idea how to make it. |
@andygrunwald care to weigh in on your preferences here? |
Thanks @hanwen @afq984 @kellyma2, for your voice. I appreciate this. I am aware that this library is used inside the google mono repo. A question to the google folks (@afq984 @dmitshur @banksean @lukegb && @hanwen): |
On the Google side I'm happy to chase the monorepo users, since I think there's relatively few impacted callsites there. There are a few uses in Chrome infrastructure as well I think but they'll probably notice when they try to update and it should be pretty obvious what to do... |
This is a large cross cutting change to the existing interfaces for go-gerrit that introduces context support to all interfaces drilling down to the HTTP level.
Contexts enable support for both passing information through (eg: tracing, logging, etc) and features like cancellation of slow operations (eg: REST calls).
In order for consumers of this breaking change to adapt their code to use the new interface they must add a context parameter to their invocations. In most cases this can just be
context.Background()
Fixes #99.