ORE Studio 0.0.4
Loading...
Searching...
No Matches
scheduler_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_SCHEDULER_MESSAGING_SCHEDULER_PROTOCOL_HPP
21#define ORES_SCHEDULER_MESSAGING_SCHEDULER_PROTOCOL_HPP
22
23#include <cstdint>
24#include <optional>
25#include <string>
26#include <string_view>
27#include <vector>
28#include "ores.scheduler.api/domain/job_definition.hpp"
29#include "ores.scheduler.api/domain/job_instance.hpp"
30
31namespace ores::scheduler::messaging {
32
33struct get_job_definitions_request {
34 using response_type = struct get_job_definitions_response;
35 static constexpr std::string_view nats_subject =
36 "scheduler.v1.job-definitions.list";
37 int offset = 0;
38 int limit = 100;
39};
40
41struct get_job_definitions_response {
42 std::vector<ores::scheduler::domain::job_definition> definitions;
43 int total_available_count = 0;
44};
45
46struct schedule_job_request {
47 using response_type = struct schedule_job_response;
48 static constexpr std::string_view nats_subject =
49 "scheduler.v1.job-definitions.schedule";
51 std::string change_reason_code;
52 std::string change_commentary;
53};
54
55struct schedule_job_response {
56 bool success = false;
57 std::string message;
58};
59
60struct unschedule_job_request {
61 using response_type = struct unschedule_job_response;
62 static constexpr std::string_view nats_subject =
63 "scheduler.v1.job-definitions.unschedule";
64 std::string job_definition_id;
65 std::string change_reason_code;
66 std::string change_commentary;
67};
68
69struct unschedule_job_response {
70 bool success = false;
71 std::string message;
72};
73
74struct schedule_jobs_batch_request {
75 using response_type = struct schedule_jobs_batch_response;
76 static constexpr std::string_view nats_subject =
77 "scheduler.v1.job-definitions.schedule-batch";
78 std::vector<ores::scheduler::domain::job_definition> definitions;
79 std::string change_reason_code;
80 std::string change_commentary;
81};
82
83struct schedule_jobs_batch_response {
84 bool success = false;
85 std::string message;
86 int scheduled_count = 0;
87 std::vector<std::string> failed_ids;
88};
89
90struct get_job_history_request {
91 using response_type = struct get_job_history_response;
92 static constexpr std::string_view nats_subject =
93 "scheduler.v1.job-definitions.history";
94 std::string job_definition_id;
95 int limit = 0;
96};
97
98struct get_job_history_response {
99 bool success = false;
100 std::string message;
101 std::vector<ores::scheduler::domain::job_instance> instances;
102};
103
104// ---------------------------------------------------------------------------
105// Job instances — global execution history view
106// ---------------------------------------------------------------------------
107
108struct get_job_instances_request {
109 using response_type = struct get_job_instances_response;
110 static constexpr std::string_view nats_subject =
111 "scheduler.v1.job-instances.list";
112 int offset = 0;
113 int limit = 100;
114};
115
123 std::int64_t id = 0;
124 std::string job_definition_id;
125 std::string job_name;
126 std::string action_type;
127 std::string status;
128 std::string triggered_at;
129 std::string started_at;
130 std::optional<std::string> completed_at;
131 std::optional<std::int64_t> duration_ms;
132 std::string error_message;
133};
134
135struct get_job_instances_response {
136 bool success = true;
137 std::string message;
138 std::vector<job_instance_summary> instances;
139 int total_available_count = 0;
140};
141
142// ---------------------------------------------------------------------------
143// Scheduler status — live overview for the Monitor window
144// ---------------------------------------------------------------------------
145
146struct get_scheduler_status_request {
147 using response_type = struct get_scheduler_status_response;
148 static constexpr std::string_view nats_subject =
149 "scheduler.v1.status";
150};
151
156 std::string job_definition_id;
157 std::string job_name;
158 std::string description;
159 std::string schedule_expression;
160 bool is_active = false;
161 std::optional<std::string> last_run_at;
162 std::optional<std::string> last_run_status;
163 std::optional<std::string> next_fire_at;
165};
166
167struct get_scheduler_status_response {
168 bool success = true;
169 std::string message;
170 std::vector<job_schedule_status> jobs;
171 int total_running = 0;
172 int total_active = 0;
173};
174
175}
176
177#endif
Persistent plan for an in-process scheduled job.
Definition job_definition.hpp:38
A job_instance enriched with the parent job's display name.
Definition scheduler_protocol.hpp:122
std::string status
"starting" | "succeeded" | "failed"
Definition scheduler_protocol.hpp:127
std::string started_at
ISO-8601 UTC.
Definition scheduler_protocol.hpp:129
std::string triggered_at
ISO-8601 UTC.
Definition scheduler_protocol.hpp:128
Per-job status snapshot used by the Scheduler Monitor window.
Definition scheduler_protocol.hpp:155
int running_count
currently running instances
Definition scheduler_protocol.hpp:164
std::optional< std::string > last_run_status
"succeeded" | "failed" | "starting"
Definition scheduler_protocol.hpp:162
std::optional< std::string > last_run_at
ISO-8601 UTC, if ever run.
Definition scheduler_protocol.hpp:161
std::optional< std::string > next_fire_at
ISO-8601 UTC, null if inactive.
Definition scheduler_protocol.hpp:163