Open
Conversation
Setting up integration with the OneFrame service. Changes made: 1. Added blaze client dependency to be able to make http calls upstream 2. Added one-frame service application configurations 3. Modified existing service port to avoid clashing with one-frame service port
Adding a live interpreter to make actual upstream service calls. Returns dummy response for now. Changes made: 1. Adding a new def live in Interpreters.scala 2. Modified Module.scala to get the live service instead of dummy 3. Created a new OneFrameLive.scala to return a dummy response.
Replace dummy response with actual call to the OneFrame API. Error handling, caching will be implemented in the next commits.
Update Currency .fromString safe in order to catch query params user errors.
Adding input validations to our proxy service. Added validations to ensure "to" and "from" are present in input request, if not, return 400 response to the client.
Added validations to ensure correct "to" and "from" currency codes from the user. If invalid, returns back 400 response. Changes include: 1. Making Currency fromString complete by adding default case 2. Using `OptionalValidatingQueryParamDecoderMatcher` instead of `OptionalQueryParamDecoderMatcher` 3. Updated RatesHttpRoutes.scala to handle input error cases, along with the case of from==to
Added error response handling from the rate service. Proxy service converts it to appropriate program level errors, and RatesHttpRoutes.scala converts it to correct http responses.
Caching rates locally from the upstream one-frame service. We leverage the fact that we can receive multiple currency pair conversion rates in a single call to the upstream service. Key considerations: 1. TTL is set to 4 mins (requirement is <5 min). Max request to upstream (60/4)*24 = 360/day, which is well within <1000/day requirement 2. If cache becomes stale or does not exist, we call the upstream with all the currency pairs possible(72) and cache them all at once locally. This greatly reduces the number of calls to the upstream (by 72x)
Added logs in key operations. Using the `log4cats-slf4j` library.
Utilizing timeouts and +1 retry on the upstream OneFrame Service. Adding these on the blaze client itself rather than at call-level since there is only 1 upstream.
1. Changed `fetchFromOneFrameAndCache` to `fetchFromOneFrame` to keep single responsible 2. Added documentation where essential 3. Minor refactors
Added Scala unit tests for the following: 1. Currency 2. OneFrameLive 3. RatesHttpRoutes
Added log statement specifying the latency in ms for each .get call to the OneFrameLive service.
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.
Live Forex Rate Proxy Implementation
This PR implements the Forex rate proxy service as part of the Paidy interview assignment. More details added in README.
Key changes:
Design decisions, assumptions, and known trade-offs are documented in the README.