Repository navigation
Adds geo-ip-service lookups, health and metrics - #2
Merged
Merged
Conversation
… with H3 cells, database health and Prometheus metrics
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
Turns geo-ip-service into a working lookup service: it loads the MaxMind GeoLite2 City and ASN databases from a directory and answers batch and single address lookups, with health and Prometheus metrics. It serves the contract
geo-ip-clientalready speaks.Changes
POST /lookupanswers a batch of addresses in request order, reportingfound,not-foundorinvalidper address, so one bad address never fails the batch.GET /lookup/:addressanswers one address.h3Resolution(0 to 15) that adds the H3 cell holding the coordinates and the cell's center.MAX_BATCH_SIZEand defaults to the client's batch size; larger batches get413.GeoLocationtype. Coordinates of zero are kept.GEOIP_DATA_DIRat startup. Each file is checked against its metadata so the wrong edition is refused.downand lookups answer503. Without ASN it reportsdegradedand keeps answering./healthzreports each edition's build date, load time and last load error./metricsexposes database load state and build time, lookups by result, requests by route and status, and batch duration in the Prometheus text format, without a metrics library.apps/geo-ip-service/test-datawith their source commit and MIT license, so tests need no license key.Verified
bun run checkunder Bun 1.4.3: typecheck clean, 80 tests pass. The service tests run the real server on the test databases and cover every status of both lookup routes, request validation, the batch limit, H3 cells, health with and without each edition, the metrics output, and a round trip throughgeo-ip-client.down, lookups503);podman stopexits0.