go-writeas icon indicating copy to clipboard operation
go-writeas copied to clipboard

context.Context support

Open abhinav opened this issue 6 years ago • 1 comments

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 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.

abhinav avatar Dec 25 '18 17:12 abhinav

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.

thebaer avatar May 26 '19 18:05 thebaer