OfflineQueue keeps events while your code cannot reach TechnicallyFit (a gym floor
system that syncs at night, a service behind an unreliable link) and sends them in order
when you call flush. Streams reach the API as summaries rather than raw sample lists:
reduce streaming device samples into summary observations before queuing them, or stream
the workout over Real-time when connected so its folded summaries
arrive as ordinary readings when the session ends.
- Checked when queued. An invalid event fails when you add it, and nothing is queued.
- Keys fixed when queued. Each event gets its idempotency key (or keeps its
source.record_id) when it is added, and the queue saves it through your storage. A flush after a crash sends the same keys, so the API answersduplicateinstead of storing anything twice. - One flush at a time. A second
flushwaits for the first and then sends only what is left, so each event is sent once. - In order. Events are sent oldest first through
POST /v1/events:bulk, in requests within the API’s limits, and the API decides each teammate’s events in that order. - Removed when answered.
acceptedandduplicateevents leave the queue. Arejectedevent leaves it too and is reported in the result, because sending the same copy again gets the same answer. A request that fails as a whole leaves its events, and every later one, in the queue.
Storage
Give the queue a storage withload and save. It saves the whole queue after every
change. MemoryStorage keeps it in memory, for tests.
flush again later.