Repository navigation
Adds geo-ip-service database updates from MaxMind - #3
Merged
Merged
Conversation
…p, persisted request interval, SIGHUP reload, one-shot update command and download stub
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.
Summary
geo-ip-service now downloads the GeoLite2 databases from MaxMind and keeps them current without a restart, while contacting MaxMind as little as possible: only when a database on the volume is missing or past its age, and never more often than a minimum interval that holds across restarts. Every part of the cycle can be exercised in seconds against a stub, and against MaxMind on demand with a one-shot command.
Changes
GEOIP_CHECK_INTERVAL, default1h). An edition is due when it is not loaded or its build is older thanGEOIP_MAX_AGE(default72h), and the last request to MaxMind for it was at leastMAXMIND_MIN_REQUEST_INTERVALago (default12h). Checking whether anything is due makes no request..mmdbMAXMIND_ACCOUNT_ID,MAXMIND_LICENSE_KEY) are read as secrets and sent only in theAuthorizationheader to MaxMind, never to the host it redirects downloads to. Without them the service never contacts MaxMind and only loads files from disk.update-state.jsonon the data volume, which is what holds the request interval across restarts.SIGHUPreloads the databases from disk without contacting MaxMind.src/update.tsruns one forced update with the same code, into the data directory or--dir, exiting1on failure, for checking credentials and the real download path right away./healthzshows each edition's update record and its next check./metricsadds whether updates are on, the last attempt time, and attempts by edition and outcome.service-kitgainsenv.durationMsfor settings such as30s,12hor3d.Verified
bun run checkunder Bun 1.4.3: typecheck clean, 103 tests pass. The update tests cover:/healthzand/metricsshowed each attempt. A restart with files on the volume made no requests.SIGHUPreloaded from disk.0with the right credentials,1with a wrong key or incomplete credentials.podman stopexits0.