Go client libraries typically accept a context.Context as the first
argument in all outgoing function calls. The context carries deadline and
other information across API boundaries. See also https://blog.golang.org/context.
Context also allows orchestrating cancelation, especially with concurrent
operations. Support for this is already built into http.Client.
Implementation
All methods that make an outgoing request would have to accept a
context.Context as their first argument and plumb it over to http.Client
with req.WithContext(ctx), likely in buildRequest or prepareRequest.
Because this will involve a breaking change to the API, it should probably be
bundled with any other breaking changes you have planned.
Great input! If anyone wants to jump on this for the v2 release of the library, please feel free to do so now. It'll be a good time to bring in this breaking change.
Overview
Go client libraries typically accept a context.Context as the first argument in all outgoing function calls. The context carries deadline and other information across API boundaries. See also https://blog.golang.org/context.
Popular examples are,
Context also allows orchestrating cancelation, especially with concurrent operations. Support for this is already built into
http.Client
.Implementation
All methods that make an outgoing request would have to accept a
context.Context
as their first argument and plumb it over tohttp.Client
withreq.WithContext(ctx)
, likely in buildRequest or prepareRequest.Because this will involve a breaking change to the API, it should probably be bundled with any other breaking changes you have planned.