LG-9433: Create USPS auth token refresh job#8721
Merged
night-jellyfish merged 14 commits intomainfrom Jul 7, 2023
Merged
Conversation
NavaTim
reviewed
Jul 5, 2023
zachmargolis
reviewed
Jul 5, 2023
zachmargolis
reviewed
Jul 6, 2023
aa710f3 to
8ea0416
Compare
NavaTim
approved these changes
Jul 6, 2023
Contributor
NavaTim
left a comment
There was a problem hiding this comment.
I think this is sufficient and functionally correct, but I highly recommend implementing the changes I suggested before merging.
[LG-9433](https://cm-jira.usa.gov/browse/LG-9433) Right now, the responsibility for renewing the authentication token lies with the methods calling out to the USPS API for any reason. This can delay requests to, for example, search for nearby post offices, as they have to first do the authentication and then do the work. Creating a USPS authentication token refresh job takes the responsibility away from the other calls to the API. They still have the logic and ability to do so as a failsafe in case all the refresh jobs fail, but if the jobs are working properly they should never need to make the call. Most of the times the job runs (every 5 minutes) it should just find a token in the cache and then stop. But if the token is under 7 minutes from expiration, then it will do the work of requesting a new token. We also added a stubbed method for testing errored requests. Tested in the Joy Sandbox successfully.
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
7b5c965 to
58a5459
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎫 Ticket
LG-9433
🛠 Summary of changes
Right now, the responsibility for renewing the authentication token lies
with the methods calling out to the USPS API for any reason. This can
delay requests to, for example, search for nearby post offices, as they
have to first do the authentication and then do the work.
Creating a USPS authentication token refresh job takes the
responsibility away from the other calls to the API. They still have the
logic and ability to do so as a failsafe in case all the refresh jobs
fail, but if the jobs are working properly they should never need to
make the call.
📜 Testing Plan
Provide a checklist of steps to confirm the changes.