#pragma once // Read access to the `queues` table, projected onto proto::Queue. taskIds is derived from // `tasks` (queue_id = this queue, ordered by queue_position), not stored on the queue row // — membership changes through download.update / queue.reorder, per Queue's own schema // note that a queue.upsert payload's taskIds is ignored. #include #include #include #include "store/sqlite.hpp" #include "velox_proto.hpp" namespace velox::daemon::store { class Queues { public: explicit Queues(Db& db) : db_(db) {} DbResult> list(); // nullopt (not an error) if no queue has this id. DbResult> get(std::string_view queue_id); // 'running' or 'stopped' (Queue.schema.json / the state column's CHECK). false if the // id doesn't exist. DbResult set_state(std::string_view queue_id, std::string_view state); // "Omit queueId to create" (queue.upsert's own words) — an empty id generates one. // taskIds is ignored (membership changes only through download.update / queue.reorder, // per the schema's own note); a create defaults to 'stopped', a replace keeps the // queue's current run state (queue.upsert edits config, not run state). DbResult upsert(velox::proto::Queue queue); private: Db& db_; }; } // namespace velox::daemon::store