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: Pace requests to token server for new auth tokens #83

Merged
merged 1 commit into from
Mar 5, 2020

Conversation

mkistler
Copy link
Contributor

@mkistler mkistler commented Mar 1, 2020

This PR adds a pacing method to regulate requests to the token service when the current token is invalid (never fetched) or expired. One caller is designated as the "active" request and it issues the request to the token server. Subsequent requests create promises that are added to a list, and the active request resolves (or rejects) these as part of processing the token server response.

Checklist
  • npm test passes (tip: npm run lint-fix can correct most style issues)
  • tests are included

@mkistler mkistler requested review from dpopp07 and ricellis March 1, 2020 19:15
@mkistler mkistler force-pushed the mdk/pace-token-requests branch 2 times, most recently from 0204158 to 79f7da1 Compare March 2, 2020 19:05
Copy link
Member

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

Took me a second to understand the approach but it looks good! The test is really great and proved the concept to me before I started mentally walking through the branches.

I left a couple of comments but they are purely stylistic, so I'm approving 👍

auth/token-managers/jwt-token-manager.ts Outdated Show resolved Hide resolved
auth/token-managers/jwt-token-manager.ts Outdated Show resolved Hide resolved
Copy link
Member

@ricellis ricellis left a comment

Choose a reason for hiding this comment

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

I think there are potentially ways this might behave unexpectedly in the case where token requests take around 1 minute, but I do think that risk is acceptable given that token requests should not be taking anywhere near that long.
Anyway I'm +1, although it might be worth resetting the requestTime when the token request completes.

auth/token-managers/jwt-token-manager.ts Show resolved Hide resolved
@mkistler mkistler force-pushed the mdk/pace-token-requests branch from dc71647 to 1f5fa56 Compare March 5, 2020 14:53
@mkistler mkistler force-pushed the mdk/pace-token-requests branch from 1f5fa56 to 9c0aab8 Compare March 5, 2020 14:58
@mkistler mkistler merged commit b14dc4e into master Mar 5, 2020
@mkistler mkistler deleted the mdk/pace-token-requests branch March 5, 2020 15:16
ibm-devx-automation pushed a commit that referenced this pull request Mar 5, 2020
# [2.2.0](v2.1.0...v2.2.0) (2020-03-05)

### Features

* Pace requests to token server for new auth tokens ([#83](#83)) ([b14dc4e](b14dc4e))
@ibm-devx-automation
Copy link

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants