-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow API to serve delayed data #34
Merged
Merged
Conversation
This file contains 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
Siegrift
force-pushed
the
delayed-data
branch
from
September 24, 2023 11:53
2063f7b
to
2ad4b6f
Compare
Siegrift
changed the title
WIP: Allow API to serve delayed data
Allow API to serve delayed data
Sep 24, 2023
andreogle
approved these changes
Sep 25, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
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.
Closes #21
Rationale
The main change is how the signed data is stored. We no longer store the latest data for each beacon, but we keep an array of data instead. This makes it easy to compute the freshest data for each endpoint while keeps the memory quite generic. With this change it is no longer possible to update signed data - pusher can only append signed data to this service which always accepts valid data (and may decide to "forget" about it is not needed).
To support multiple endpoints, it is clear we need some configuration. I opted for
signed-api.json
with basic schema that allows to configure an endpoint with a delay (currently without auth). The signed API ignores all data that is too fresh and was submitted after"Date.now() - delayInMs"
. I then realized, we no longer need the ENV file and can instead merge this with the config (so that we have a single file to maintain).I added some basic tests and minor refactors to simplify the code.
Note, that I have not added support for pruning old data and instead created a separate issue #35 since the PR is quite big already.