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(1961): Replace request package with got #45

Merged
merged 5 commits into from
Aug 17, 2021
Merged

feat(1961): Replace request package with got #45

merged 5 commits into from
Aug 17, 2021

Conversation

tkyi
Copy link
Member

@tkyi tkyi commented Jul 21, 2021

Context

It would be nice to replace deprecated request package with a different one.

Objective

This PR attempts to replace request package with got package.

TODO:

  • handle retries

References

Related to screwdriver-cd/screwdriver#1961

License

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

index.js Outdated Show resolved Hide resolved
package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

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

remove package-lock

Copy link
Member Author

Choose a reason for hiding this comment

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

hm it was already there

index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@pritamstyz4ever pritamstyz4ever left a comment

Choose a reason for hiding this comment

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

We can create a new library sd-request or sd-got which will act as a wrapper for the underlying got library and have REST API operations get|put|post|delete built into it , this will make it more reusable and easy to refactor, change, upgrade in the future.

@tkyi
Copy link
Member Author

tkyi commented Jul 26, 2021

Created new library: https://github.com/screwdriver-cd/request

@tkyi tkyi marked this pull request as ready for review July 28, 2021 22:31
* @return {Promise} Resolves when no error encountered.
* Rejects when status code is non-200
*/
function checkResponseError(response, caller) {
Copy link
Member Author

Choose a reason for hiding this comment

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

jithine
jithine previously approved these changes Aug 9, 2021
Copy link
Member

@jithine jithine left a comment

Choose a reason for hiding this comment

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

Is retry still now handled like the PR description suggests ?

Also https://github.com/screwdriver-cd/request/blob/master/index.js#L50 shouldn't this be a number ?

index.js Outdated Show resolved Hide resolved

this.breaker = new Breaker(Request, this.config.fusebox);
// eslint-disable-next-line no-underscore-dangle
this.breaker = new Breaker(this._gitlabCommand.bind(this), {
Copy link
Member

@jithine jithine Aug 9, 2021

Choose a reason for hiding this comment

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

why continue to use breaker? Why not use the native retry capabilities of the library https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md

Sine we are rewriting, we might as well not rely on a library like circuit-fuses which is still callback based.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was my understanding that circuit breaker vs retry are not exactly the same thing:

It might be good to look for replacements or upgrades to the circuit-fuses library, but I think that is out of scope for this issue. Also, I'd rather not change two major packages at the same time.

index.js Outdated
qs: {
token,
route: `users`,
json: {
Copy link
Member

@jithine jithine Aug 9, 2021

Choose a reason for hiding this comment

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

how come json is being passed for GET request ?

Also for we seem to be using https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#allowgetbody , why ? This looks like we are changing how GET parameters are being passed passed from query string to request body, and is now at the mercy of http server to do the right thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we needed to pass qs as json but it should be searchParams
fixed: screwdriver-cd/request#4

@jithine jithine dismissed their stale review August 9, 2021 23:22

need couple more clarifications

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.

3 participants