-
Notifications
You must be signed in to change notification settings - Fork 49
Please reintroduce context.Context #255
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
Please reintroduce context.Context #255
Comments
Running into this issue as it also prevents tracing from working properly |
This is really pretty annoying. We are now creating a new client with this workaround: // forceContextRoundTripper sets the given context on every request and passes it to the wrapped RoundTripper
type forceContextRoundTripper struct {
roundTripper http.RoundTripper
ctx context.Context
}
func (f *forceContextRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
req = req.Clone(f.ctx)
return f.roundTripper.RoundTrip(req)
}
// NewClient creates a twilio client whose HTTP requests are bound by the passed context.
// This is required because their package doesn't expose the context param per operation...
func NewClient(ctx context.Context) *twilio.RestClient {
c := twilio.NewRestClientWithParams(twilio.ClientParams{
Username: env.TwilioAccountSid,
Password: env.TwilioAuthToken,
})
httpClient := utils.NewHttpClient(5*time.Second, 100)
httpClient.Transport = &forceContextRoundTripper{
ctx: ctx,
roundTripper: httpClient.Transport,
}
c.RequestHandler.Client.(*twilioClient.Client).HTTPClient = httpClient
return c
} |
Hi! We have added this request (DII-1926) to our internal backlog. +1/upvotes will help bring this up the priority. Thanks! |
@Hades32 Nice, so you make a new client for every incoming request to associate the requests made by the client with the original request? Hacky but workable, thanks |
We are actively working on this. We will try to release this as soon as possible |
Issue Summary
This is a duplicate of #98 which has been closed with no update.
context.Context
support was introduced in https://github.com/twilio/twilio-go/blob/main/CHANGES.md#2022-11-10-version-120 then mysteriously revertedSteps to Reproduce
N/A
Code Snippet
N/A
Exception/Log
N/A
Technical details:
The text was updated successfully, but these errors were encountered: