ludic/packages/ludic.telemetry/facts.ludic
Orkuncakilkaya d1bea7f10e fix(ludic.telemetry): nothing made per event - properties and the line written into kept buffers, the queue a ring of bytes made at the start
An event was a tree of values encoded into a new string, a dropped line was never given back, and
every batch and save joined the queue into another. Now: telemetry_props / telemetry_str / _int /
_bool write the properties as JSON into a buffer the state keeps; the line is written beside it,
its time worked out from the clock's seconds (TelemetryWorld.clock_s, was stamp); its bytes go
into one ring (ring_bytes, at most queue_max lines), the oldest overwritten past either; a batch
and the file are written into a third kept buffer and go as bytes (TelemetryTransport.send takes
the bytes and their length; Http.body_bytes, Fs.write_bytes). The facts are pooled.
tests/ring_test: ten thousand events past the cap in lines and in bytes, 0 bytes of heap; the line
exact JSON, escaped, 2000-02-29 right; the batch puts the id in; the file round-trips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 15:15:12 +03:00

16 lines
793 B
Text

# facts.ludic - a fact's record reused (the ludic.wildlife idiom): a batch sent or failed is a fact
# a fact record no drain holds any more, made (and kept) only when every one is held
function telemetry__fact_record(telemetry_st: mut TelemetryState) -> TelemetryFact {
if telemetry_st.telemetry__fnext[0] >= len(telemetry_st.telemetry__ffree) {
q_unheld(telemetry_st.telemetry__facts, telemetry_st.telemetry__fpool, telemetry_st.telemetry__ffree)
telemetry_st.telemetry__fnext[0] = 0
}
if telemetry_st.telemetry__fnext[0] < len(telemetry_st.telemetry__ffree) {
let f = telemetry_st.telemetry__ffree[telemetry_st.telemetry__fnext[0]]
telemetry_st.telemetry__fnext[0] += 1
return f
}
let f = new TelemetryFact
push(telemetry_st.telemetry__fpool, f)
return f
}