ORE Studio 0.0.4
Loading...
Searching...
No Matches
job_instance.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#pragma once
21
22#include <chrono>
23#include <cstdint>
24#include <optional>
25#include <string>
26#include <boost/uuid/uuid.hpp>
27#include "ores.scheduler.api/domain/job_status.hpp"
28
29namespace ores::scheduler::domain {
30
37struct job_instance final {
38 std::int64_t id = 0;
39 std::optional<boost::uuids::uuid> tenant_id;
40 std::optional<boost::uuids::uuid> party_id;
41 boost::uuids::uuid job_definition_id;
42 std::string action_type;
43 job_status status = job_status::starting;
44 std::chrono::system_clock::time_point triggered_at;
45 std::chrono::system_clock::time_point started_at;
46 std::optional<std::chrono::system_clock::time_point> completed_at;
47 std::optional<std::int64_t> duration_ms;
48 std::string error_message;
49
53 [[nodiscard]] std::optional<std::chrono::milliseconds> duration() const noexcept {
54 if (!duration_ms) return std::nullopt;
55 return std::chrono::milliseconds(*duration_ms);
56 }
57};
58
59} // namespace ores::scheduler::domain
A record of a single in-process job execution.
Definition job_instance.hpp:37
std::optional< std::chrono::milliseconds > duration() const noexcept
Wall-clock duration of the execution, if it has completed.
Definition job_instance.hpp:53