twilio / twilio-go

A Go package for communicating with the Twilio API.
MIT License
280 stars 40 forks source link

context.Context support is missing #98

Closed brenol closed 1 year ago

brenol commented 3 years ago

Issue Summary

Not really a bug, but a missing functionality. Expected to see methods with context.Context support. However, currently there is no support for it and this makes it not being possible to do proper cancellation with twilio's API.

Code Snippet

N/A

Exception/Log

N/A

Technical details:

thinkingserious commented 3 years ago

Hello @brenol,

Thank you for taking the time to report this feature request! This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

With best regards,

Elmer

kevinburke commented 3 years ago

You might want to also add a note in the README that the API is going to change, unless you are going to double up every single endpoint like AWS does (CreateMessage and CreateMessageWithContext, etc.)

natebrennand commented 2 years ago

Hi @thinkingserious , I'd be willing to take this on if you can direct me on how you want the API's evolved. I really appreciate the ability to provide your own HTTP client, but not having accessing the context.Context is limiting our ability to instrument the client.

I envision that both the client's and API packages are going to need meaningful changes to accommodate this:

Approach 1 - break API's:

Approach 2 - deprecate and expose API's w/ context.

I'm generally assuming y'all would prefer adding methods rather than breaking. Please let me know how you'd like these changes to look.

rakatyal commented 1 year ago

Hi @natebrennand, thank you for your suggestions! We like the approach 2, if you could submit a PR with a proof of concept, we will work on getting the changes inside the generator.

natebrennand commented 1 year ago

Hi @natebrennand, thank you for your suggestions! We like the approach 2, if you could submit a PR with a proof of concept, we will work on getting the changes inside the generator.

I've got PR's open to update the underlying client and the SDK to support this:

kbolino commented 1 year ago

Am I missing something? This is marked as done but version 1.7.1 of the API, released 5 days ago, does not seem to have support for context.

For example, the signature of CreateVerification looks like this:

func (c *ApiService) CreateVerification(ServiceSid string, params *CreateVerificationParams) (*VerifyV2Verification, error)

whereas I'm expecting it to look like this:

func (c *ApiService) CreateVerification(ctx context.Context, ServiceSid string, params *CreateVerificationParams) (*VerifyV2Verification, error)
Makpoc commented 11 months ago

Hello. I'd like to repeat the last question from kbolino. Support for context was added and then reverted with e89399c and 79f196e . Was this intentional change or was it a bad merge/regenerate?

Kcrong commented 2 months ago

Hi. I'd like to inquire about any updates regarding this issue.

mwajeeh commented 1 month ago

Any update here?