Kiosk: schedule client (conditional GET + atomic cache) and engine
Adds api_client support for GET /licenses/{key}/schedule with If-None-Match
and target-payload parsing (version/type/daily/weekly + legacy blocks), an
atomic on-disk schedule cache, a pure schedule engine (half-open blocks,
midnight self-wrap for daily, Sunday->Monday spillover for weekly, invalid
blocks skipped with a warning), and a background ScheduleManager that loads
the cache offline and pulls on boot and every 5 minutes. Adds engine/cache
tests against the shared docs/fixtures, including 304, corrupt cache, and
offline cases.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "network/api_client.h"
|
||||
#include <string>
|
||||
|
||||
namespace radiantwave::sync {
|
||||
|
||||
// The on-disk schedule cache. Stores the target payload plus its ETag as a JSON
|
||||
// document. Writes are atomic (temp file + rename) so a crash or power loss
|
||||
// never leaves a partially written cache.
|
||||
namespace schedule_cache {
|
||||
|
||||
// Absolute path of the cache file (under ~/.local/radiantwave/).
|
||||
std::string cachePath();
|
||||
|
||||
// Serialize `payload`/`etag` to the cache file atomically. Returns false on
|
||||
// any I/O failure; the previous cache is left intact.
|
||||
bool write(const api::SchedulePayload& payload, const std::string& etag);
|
||||
|
||||
// Load the cache. Returns false (and leaves `out` untouched) when the file is
|
||||
// missing, unreadable, malformed, or semantically invalid.
|
||||
bool read(api::SchedulePayload& out, std::string& outEtag);
|
||||
|
||||
// Remove the cache file. Returns true when absent afterwards.
|
||||
bool clear();
|
||||
|
||||
} // namespace schedule_cache
|
||||
|
||||
} // namespace radiantwave::sync
|
||||
Reference in New Issue
Block a user