32#include "reusex/pipeline/JobStore.hpp"
33#include "reusex/pipeline/job_types.hpp"
34#include "reusex/pipeline/stages.hpp"
60 std::shared_ptr<IJobStore>
store =
nullptr);
74 std::unique_ptr<JobQueue>
75 make_queue(std::string key, std::filesystem::path project,
89 std::shared_ptr<Core> core_;
105 const std::string &
key() const noexcept;
106 const std::filesystem::path &
project() const noexcept;
115 std::string submitted_by = {});
122 std::optional<JobRecord>
job(std::string_view
id)
const;
125 std::vector<JobRecord>
jobs()
const;
155 std::shared_ptr<State> state);
157 std::shared_ptr<JobScheduler::Core> core_;
158 std::shared_ptr<State> state_;
Persistence for job records. Implementations must be thread-safe.
One project's jobs on a JobScheduler. Every member is thread-safe.
JobQueue & operator=(const JobQueue &)=delete
void remove_listener(std::size_t token)
JobQueue(const JobQueue &)=delete
bool is_busy() const
True while one of this queue's jobs is executing.
WriterLease try_acquire_writer(std::chrono::milliseconds timeout)
Try to take the project's exclusive writer lock (see JobRunner).
friend class JobScheduler
Implementation detail.
std::size_t queued_count() const
Jobs of this queue still waiting to start.
const std::filesystem::path & project() const noexcept
bool cancel(std::string_view id)
Request cancellation (queued: cancelled now; running: cancel token set; terminal: no-op).
std::size_t add_listener(JobListener listener)
Register a listener for this queue's events. Returns a removal token.
const std::string & key() const noexcept
std::string submit(JobStage stage, std::string parameters={}, std::string submitted_by={})
Enqueue a stage run.
std::optional< JobRecord > job(std::string_view id) const
Snapshot of one of this queue's jobs, or nullopt if unknown or evicted.
void wait_idle()
Block until this queue has nothing queued, nothing running and every event delivered.
std::vector< JobRecord > jobs() const
Every retained job of this queue, most recently submitted first.
bool has_work() const
True while a job is queued or running, or an event is still being delivered to the listeners — read u...
~JobQueue()
Closes the queue: queued jobs are reported cancelled, a running job is asked to stop,...
std::shared_ptr< IJobStore > store() const
The store records are written to.
~JobScheduler()
Cancels every queued job (reported as cancelled), asks every running job to stop, and joins the worke...
std::size_t workers() const noexcept
JobScheduler & operator=(const JobScheduler &)=delete
JobScheduler(JobSchedulerOptions options={}, std::shared_ptr< IJobStore > store=nullptr)
std::size_t running_count() const
Jobs executing right now, across every queue.
std::unique_ptr< JobQueue > make_queue(std::string key, std::filesystem::path project, StageExecutor executor=default_stage_executor())
A new queue for project.
JobScheduler(const JobScheduler &)=delete
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
std::function< void(const JobEvent &)> JobListener
Listener callback.
JobStage
A pipeline stage that can be executed as a job.
StageExecutor default_stage_executor()
The executor that actually runs the pipeline (a thin wrap of run_stage).
std::function< StageResult(const StageContext &)> StageExecutor
Stage execution strategy.
std::unique_lock< std::timed_mutex > WriterLease
Exclusive right to write to a runner's project.
std::size_t workers
Worker threads, i.e.