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

refactor: remove configurable request #394

Merged
merged 1 commit into from Mar 28, 2019
Merged

refactor: remove configurable request #394

merged 1 commit into from Mar 28, 2019

Conversation

JustinBeckwith
Copy link
Contributor

BREAKING CHANGE: This PR removes the ability to configure a custom implementation of the Request module. This was necessary when we were migrating from request to teeny-request, but that migration is now complete. All interfaces at accepted a custom implementation of request will no longer accept one. teeny-request is now just included in the box.

This change is being made to simplify the request interface touch points.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 27, 2019
@JustinBeckwith
Copy link
Contributor Author

FYI @ofrobots, this is in pursuit of #392

@codecov
Copy link

codecov bot commented Mar 27, 2019

Codecov Report

Merging #394 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   98.52%   98.51%   -0.01%     
==========================================
  Files           5        5              
  Lines         338      336       -2     
  Branches       51       50       -1     
==========================================
- Hits          333      331       -2     
  Misses          3        3              
  Partials        2        2
Impacted Files Coverage Δ
src/service.ts 97.91% <ø> (-0.05%) ⬇️
src/service-object.ts 98.86% <ø> (-0.03%) ⬇️
src/util.ts 98.17% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04b5610...52927f4. Read the comment docs.

2 similar comments
@codecov
Copy link

codecov bot commented Mar 27, 2019

Codecov Report

Merging #394 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   98.52%   98.51%   -0.01%     
==========================================
  Files           5        5              
  Lines         338      336       -2     
  Branches       51       50       -1     
==========================================
- Hits          333      331       -2     
  Misses          3        3              
  Partials        2        2
Impacted Files Coverage Δ
src/service.ts 97.91% <ø> (-0.05%) ⬇️
src/service-object.ts 98.86% <ø> (-0.03%) ⬇️
src/util.ts 98.17% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04b5610...52927f4. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 27, 2019

Codecov Report

Merging #394 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   98.52%   98.51%   -0.01%     
==========================================
  Files           5        5              
  Lines         338      336       -2     
  Branches       51       50       -1     
==========================================
- Hits          333      331       -2     
  Misses          3        3              
  Partials        2        2
Impacted Files Coverage Δ
src/service.ts 97.91% <ø> (-0.05%) ⬇️
src/service-object.ts 98.86% <ø> (-0.03%) ⬇️
src/util.ts 98.17% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04b5610...52927f4. Read the comment docs.

@@ -178,8 +171,6 @@ class ServiceObject<T = any> extends EventEmitter {
this.methods = config.methods || {};
this.interceptors = [];
this.Promise = this.parent ? this.parent.Promise : undefined;
this.requestModule =
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be nice to throw if config.requestModule is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I seem to remember @stephenplusplus smacking my hands last time I did something like that in this exact spot :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha. Well, throwing developer errors hasn't been something we have done before. We only throw errors that make sense to the user, and leave it to our various testing mechanisms to cover how we use our own libraries.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a different use-case though. We are detecting that the user didn't read the changelog and is passing a config flag that we are going to silently ignore. It would be nice to tell them that there was a breaking change. I don't have objections to the general disposition about throwing errors in these libraries; but this is different.

Copy link
Contributor

Choose a reason for hiding this comment

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

The users are us, though.

Sorry, submitted prematurely. But, the difference I see is that this library is just an abstraction of formerly internal code to the various APIs. So, it's not that users are providing this option, it was only done by us from the constructors in those APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am wildly irresponsible and really rely on TypeScript types and aggressive exceptions to save me from myself 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen (and like) the pattern of asserting that arguments/config are correct at the start of a function, so that a client fails as early as possible when interacting with the library (vs., having undefined behavior that bubbles as an error like can't access property of undefined).

Having said this, given we're calling this a breaking change and, like @stephenplusplus says, this is an interface probably mainly used by ourselves, I'd argue against the throw (which we'll then wonder about why the heck it's in the codebase for the next 5 years).

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

this is great:

  • I really like the pattern you used for the migration.
  • I've learned about teeny-request, which I'm excited to use in my own libraries.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants