ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
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
24
namespace
reusex::pipeline
{
25
32
enum class
JobStatus
{
33
queued
,
34
running
,
35
succeeded
,
36
failed
,
37
cancelled
,
38
};
39
41
std::string_view
to_string
(
JobStatus
status);
42
44
std::optional<JobStatus>
parse_job_status
(std::string_view name);
45
47
bool
is_terminal
(
JobStatus
status);
48
50
std::string
iso8601_utc_now
();
51
53
struct
JobRecord
{
54
std::string
id
;
55
JobStage
stage
=
JobStage::clouds
;
56
JobStatus
status
=
JobStatus::queued
;
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
68
core::Stage
progress_stage
=
core::Stage::idle
;
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
82
struct
JobEvent
{
92
uint64_t
sequence
= 0;
93
94
enum class
Type
{
95
submitted,
96
started,
97
progress,
98
finished,
99
};
100
101
Type
type
=
Type::submitted
;
102
std::string
timestamp
;
103
JobRecord
job
;
104
};
105
107
std::string_view
to_string
(
JobEvent::Type
type);
108
111
using
JobListener
= std::function<void(
const
JobEvent
&)>;
112
118
using
WriterLease
= std::unique_lock<std::timed_mutex>;
119
120
}
// namespace reusex::pipeline
reusex::core::Stage
Stage
Definition
stages.hpp:11
reusex::core::Stage::idle
@ idle
Definition
stages.hpp:12
reusex::pipeline
Definition
job_types.hpp:24
reusex::pipeline::JobListener
std::function< void(const JobEvent &)> JobListener
Listener callback.
Definition
job_types.hpp:111
reusex::pipeline::parse_job_status
std::optional< JobStatus > parse_job_status(std::string_view name)
Parse a canonical status name. Returns nullopt for an unknown name.
reusex::pipeline::to_string
std::string_view to_string(JobStatus status)
Canonical lower-case status name used on the wire.
reusex::pipeline::JobStage
JobStage
A pipeline stage that can be executed as a job.
Definition
stages.hpp:43
reusex::pipeline::JobStage::clouds
@ clouds
back-project sensor frames into "cloud" + "normals"
Definition
stages.hpp:44
reusex::pipeline::iso8601_utc_now
std::string iso8601_utc_now()
UTC timestamp in ISO-8601 form (e.g. "2026-09-08T11:22:33Z").
reusex::pipeline::JobStatus
JobStatus
Lifecycle of a submitted job.
Definition
job_types.hpp:32
reusex::pipeline::JobStatus::failed
@ failed
Definition
job_types.hpp:36
reusex::pipeline::JobStatus::cancelled
@ cancelled
Definition
job_types.hpp:37
reusex::pipeline::JobStatus::running
@ running
Definition
job_types.hpp:34
reusex::pipeline::JobStatus::queued
@ queued
Definition
job_types.hpp:33
reusex::pipeline::JobStatus::succeeded
@ succeeded
Definition
job_types.hpp:35
reusex::pipeline::WriterLease
std::unique_lock< std::timed_mutex > WriterLease
Exclusive right to write to a runner's project.
Definition
job_types.hpp:118
reusex::pipeline::is_terminal
bool is_terminal(JobStatus status)
True for statuses a job can never leave.
reusex::pipeline::JobEvent
One notification about a job.
Definition
job_types.hpp:82
reusex::pipeline::JobEvent::type
Type type
Definition
job_types.hpp:101
reusex::pipeline::JobEvent::timestamp
std::string timestamp
ISO-8601 UTC.
Definition
job_types.hpp:102
reusex::pipeline::JobEvent::sequence
uint64_t sequence
Monotonic emission order, starting at 1.
Definition
job_types.hpp:92
reusex::pipeline::JobEvent::Type
Type
Definition
job_types.hpp:94
reusex::pipeline::JobEvent::Type::submitted
@ submitted
Accepted onto the queue.
Definition
job_types.hpp:95
reusex::pipeline::JobEvent::job
JobRecord job
Definition
job_types.hpp:103
reusex::pipeline::JobRecord
A job as reported by the runner. Snapshot; never a live view.
Definition
job_types.hpp:53
reusex::pipeline::JobRecord::submitted_at
std::string submitted_at
ISO-8601 UTC.
Definition
job_types.hpp:59
reusex::pipeline::JobRecord::progress_total
size_t progress_total
0 = indeterminate.
Definition
job_types.hpp:70
reusex::pipeline::JobRecord::started_at
std::string started_at
ISO-8601 UTC; empty while queued.
Definition
job_types.hpp:60
reusex::pipeline::JobRecord::error
std::string error
Failure reason; empty unless status == failed.
Definition
job_types.hpp:58
reusex::pipeline::JobRecord::cancel_requested
bool cancel_requested
Definition
job_types.hpp:65
reusex::pipeline::JobRecord::parameters
std::string parameters
JSON object as submitted ("" = defaults).
Definition
job_types.hpp:57
reusex::pipeline::JobRecord::progress_stage
core::Stage progress_stage
Live progress, mirrored from the stage's core::ProgressObserver.
Definition
job_types.hpp:68
reusex::pipeline::JobRecord::stage
JobStage stage
Definition
job_types.hpp:55
reusex::pipeline::JobRecord::result_outputs
std::vector< StageArtifact > result_outputs
Definition
job_types.hpp:77
reusex::pipeline::JobRecord::progress_current
size_t progress_current
Definition
job_types.hpp:69
reusex::pipeline::JobRecord::finished_at
std::string finished_at
ISO-8601 UTC; empty until terminal.
Definition
job_types.hpp:61
reusex::pipeline::JobRecord::result_summary
std::string result_summary
The stage's own summary of what it produced, and the artifacts it wrote.
Definition
job_types.hpp:76
reusex::pipeline::JobRecord::id
std::string id
Opaque server-generated identifier (GUID).
Definition
job_types.hpp:54
reusex::pipeline::JobRecord::status
JobStatus status
Definition
job_types.hpp:56
reusex::pipeline::JobRecord::submitted_by
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
libs
reusex
include
pipeline
job_types.hpp
Generated by
1.18.0