Skip to content
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

feat: add context.Context support to Go SDK #301

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

natebrennand
Copy link

@natebrennand natebrennand commented Oct 30, 2022

Fixes twilio-go#98

This PR updates the mustache templates that generate the Go client to leverage the context request methods that will be introduced in: twilio/twilio-go#196

The newly generated SDK is available at twilio/twilio-go#197.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • Run make test-docker
  • Verify affected language:
    • Generate twilio-go from our OpenAPI specification using the build_twilio_go.py using python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go and inspect the diff
    • Run make test in twilio-go
    • Create a pull request in twilio-go
    • Provide a link below to the pull request
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

@natebrennand natebrennand force-pushed the natebrennand/add-context-methods-to-SDK branch 3 times, most recently from 50217bf to 12c8e79 Compare October 30, 2022 01:32
@rakatyal
Copy link
Contributor

@natebrennand: Thanks for the PR! Haven't tested this locally yet, but could you look at what the test failures are about?

@natebrennand
Copy link
Author

It's kinda hard to get the failures to surface. Ultimately accessed it via the docker logs.

$ docker logs -f ecab475126e4
# go-client/helper/rest/api/v2010
helper/rest/api/v2010/api_service.go:23:25: undefined: client.RequestHandlerWithCtx
helper/rest/api/v2010/api_service.go:27:37: undefined: client.UpgradeRequestHandler
helper/rest/api/v2010/api_service.go:30:50: undefined: client.RequestHandlerWithCtx
helper/rest/api/v2010/api_service.go:41:51: undefined: client.BaseClientWithCtx
helper/rest/api/v2010/api_service.go:42:37: undefined: client.NewRequestHandlerWithCtx
helper/rest/api/v2010/accounts.go:290:25: undefined: client.GetNextWithCtx
# go-client/helper/rest/flex/v1
helper/rest/flex/v1/api_service.go:23:25: undefined: client.RequestHandlerWithCtx
helper/rest/flex/v1/api_service.go:27:37: undefined: client.UpgradeRequestHandler
helper/rest/flex/v1/api_service.go:30:50: undefined: client.RequestHandlerWithCtx
helper/rest/flex/v1/api_service.go:41:51: undefined: client.BaseClientWithCtx
helper/rest/flex/v1/api_service.go:42:37: undefined: client.NewRequestHandlerWithCtx
helper/rest/flex/v1/credentials_aws.go:381:25: undefined: client.GetNextWithCtx
{"Time":"2022-10-31T21:13:25.825735012Z","Action":"output","Package":"go-client/helper/client","Output":"?   \tgo-client/helper/client\t[no test files]\n"}
{"Time":"2022-10-31T21:13:25.829743346Z","Action":"skip","Package":"go-client/helper/client","Elapsed":0.004}
FAIL	go-client/helper/rest/api/v2010 [build failed]
FAIL	go-client/helper/rest/flex/v1 [build failed]
FAIL	go-client/terraform/resources/api/v2010 [build failed]
FAIL	go-client/terraform/resources/flex/v1 [build failed]

Looks like we'll need to land the first of two commits in 197 that adds new methods to the client: https://github.com/twilio/twilio-go/pull/197/commits

I'll separate that PR.

@natebrennand
Copy link
Author

@rakatyal, twilio/twilio-go#196 has the changes to the underlying client that will be needed before this PR's tests will pass.

@natebrennand natebrennand force-pushed the natebrennand/add-context-methods-to-SDK branch from d1fb508 to 228615e Compare November 8, 2022 19:58
@natebrennand
Copy link
Author

@childish-sambino, I did a rebase on this PR to update w/ master and try to re-prompt the CI so I removed the merge commit. I think you may need to re-enqueue the build?

@natebrennand natebrennand force-pushed the natebrennand/add-context-methods-to-SDK branch from 228615e to 2ec6804 Compare November 8, 2022 20:50
@natebrennand
Copy link
Author

Sorry, iteration speed is slow here because it's a bit obtuse to access the test results. It seems I had to regenerate the some of the examples here too. I've amended the last commit to include these.

Copy link
Contributor

@childish-sambino childish-sambino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean. Thanks!

@natebrennand
Copy link
Author

natebrennand commented Nov 8, 2022

@childish-sambino, if that diff is necessary on the tests, I think my statements on #196 may have been incorrect. If this test client needs to be amended to get the tests to work, things are busted.


When I ran the tests locally without your added commit I got failures in go-client/helper/rest/api/v2010.TestDateTimeQueryParams & go-client/helper/rest/flex/v1.TestGet:

connect: connection refused

I cannot tell if this is related to the docker-compose setup or what exactly.

@childish-sambino
Copy link
Contributor

@natebrennand The error you're seeing is the result of not being linked up with the prism servers defined in the docker-compose file. The failing tests are attempting to connect to the prism instance to verify expected behaviors.

The reason why they're failing even when run with docker-compose is that this method is not being called to swap the scheme from https to http: TestClient.getParsedUrl

The TestClient is meant to wrap the Client and provide its own SendRequest implementation which changes the scheme of the request to http and pass the request along to the underlying Client. But, because we're wrapping Client which does indeed define SendReqeustWithCtx, the TestClient meets the interface requirements for BaseClientWithCtx and the wrapperClient is not used.

@childish-sambino
Copy link
Contributor

FYI, I'm going to revert the changes to twilio-go until this is resolved so they don't affect the next release.

@jacopoRufini
Copy link

Hi, any news for this?

@claudiachua
Copy link
Contributor

Update: Internal Backlog Reference (DI-2543)

@fred-marigold
Copy link

It's nearly two months since the last update - can you give some insight on when this feature may be available?

@sheregeda
Copy link

Hi, do you have any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

context.Context support is missing
8 participants