Add the keygrabber sample, sink contract, retry queue and InfluxDB sink - #32
Merged
Merged
Conversation
mikelangmayr
force-pushed
the
mike/keygrabber-sink
branch
from
September 16, 2026 18:54
acf17fc to
1037a79
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.
First slice of the keygrabber: the storage boundary only. No daemon, no polling and no config yet, so nothing here runs on its own.
libby/keygrabber/withSample(keyword, group, peer, value, units, timestamp) and aSinkprotocol ofconnect/is_connected/write/close. Nothing inSampleis Influx-shaped, so a second backend is a new sink rather than a change to the collectorwritereturns how many samples it stored, which can be fewer than it was handed, and raisesSinkWriteErrorwhen a batch failed and is worth retryingRetryingWriter, which wraps any sink and holds failed batches in a bounded queue with exponential backoff, dropping oldest when full so a database that stays down cannot grow memory without limit. It starts no thread and never sleeps: the caller drivesflush_due()and the clock is injectable, so the backoff tests run in a millisecondInfluxSinkfor InfluxDB 2.x: one measurement per keyword name, tagsgroup/peer/units, singlevaluefield, whole batch as one requestlasterroris nullable on every daemon andNonemost of the time, so a collection reading a whole peer would otherwise fail on every tick. Confirmed live against a daemon: a%read returnslasterroras{"ok": true, "value": null}0and another0.5for the same keyword cannot collide as int against float and have the write rejected.boolis checked first, being a subclass ofintnoneplaceholder, since Influx drops an empty tag value and a keyword would otherwise split across two series depending on whether it declared unitsInfluxConfig.__repr__, so a traceback or a logged config cannot leak itinfluxdbextra and install it in the tox test env, so the sink's tests run in CI instead of skipping. They skip cleanly when it is absentlibby.keygrabber.sinkto the API reference; the Influx module is left out because it imports its client at module scope and the docs build does not install the extra-Wdocs build verified locally. The write path is covered against an injected write API and the point mapping against the real client's line-protocol serializer; no live InfluxDB server was exercised