ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
job_types.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7// The vocabulary shared by every job runner: a job's record, its status, the
8// events it raises, and the writer lease that makes a running stage exclusive
9// with other writers of the same project. Split out of JobRunner.hpp so the
10// JobScheduler and the job stores can use it without the runner.
11
12#include "reusex/core/stages.hpp"
13#include "reusex/pipeline/stages.hpp"
14
15#include <cstddef>
16#include <cstdint>
17#include <functional>
18#include <mutex>
19#include <optional>
20#include <string>
21#include <string_view>
22#include <vector>
23
25
39
41std::string_view to_string(JobStatus status);
42
44std::optional<JobStatus> parse_job_status(std::string_view name);
45
48
50std::string iso8601_utc_now();
51
53struct JobRecord {
54 std::string id;
57 std::string parameters;
58 std::string error;
59 std::string submitted_at;
60 std::string started_at;
61 std::string finished_at;
64 std::string submitted_by;
65 bool cancel_requested = false;
66
69 size_t progress_current = 0;
70 size_t progress_total = 0;
71
76 std::string result_summary;
77 std::vector<StageArtifact> result_outputs;
78};
79
82struct JobEvent {
92 uint64_t sequence = 0;
93
94 enum class Type {
95 submitted,
96 started,
97 progress,
98 finished,
99 };
100
102 std::string timestamp;
104};
105
107std::string_view to_string(JobEvent::Type type);
108
111using JobListener = std::function<void(const JobEvent &)>;
112
118using WriterLease = std::unique_lock<std::timed_mutex>;
119
120} // namespace reusex::pipeline
std::function< void(const JobEvent &)> JobListener
Listener callback.
std::optional< JobStatus > parse_job_status(std::string_view name)
Parse a canonical status name. Returns nullopt for an unknown name.
std::string_view to_string(JobStatus status)
Canonical lower-case status name used on the wire.
JobStage
A pipeline stage that can be executed as a job.
Definition stages.hpp:43
@ clouds
back-project sensor frames into "cloud" + "normals"
Definition stages.hpp:44
std::string iso8601_utc_now()
UTC timestamp in ISO-8601 form (e.g. "2026-09-08T11:22:33Z").
JobStatus
Lifecycle of a submitted job.
Definition job_types.hpp:32
std::unique_lock< std::timed_mutex > WriterLease
Exclusive right to write to a runner's project.
bool is_terminal(JobStatus status)
True for statuses a job can never leave.
One notification about a job.
Definition job_types.hpp:82
std::string timestamp
ISO-8601 UTC.
uint64_t sequence
Monotonic emission order, starting at 1.
Definition job_types.hpp:92
@ submitted
Accepted onto the queue.
Definition job_types.hpp:95
A job as reported by the runner. Snapshot; never a live view.
Definition job_types.hpp:53
std::string submitted_at
ISO-8601 UTC.
Definition job_types.hpp:59
size_t progress_total
0 = indeterminate.
Definition job_types.hpp:70
std::string started_at
ISO-8601 UTC; empty while queued.
Definition job_types.hpp:60
std::string error
Failure reason; empty unless status == failed.
Definition job_types.hpp:58
std::string parameters
JSON object as submitted ("" = defaults).
Definition job_types.hpp:57
core::Stage progress_stage
Live progress, mirrored from the stage's core::ProgressObserver.
Definition job_types.hpp:68
std::vector< StageArtifact > result_outputs
Definition job_types.hpp:77
std::string finished_at
ISO-8601 UTC; empty until terminal.
Definition job_types.hpp:61
std::string result_summary
The stage's own summary of what it produced, and the artifacts it wrote.
Definition job_types.hpp:76
std::string id
Opaque server-generated identifier (GUID).
Definition job_types.hpp:54
std::string submitted_by
Who submitted it — an opaque id the caller chose (ruxd: the user id); empty when nobody in particular...
Definition job_types.hpp:64