Skip to main content

reifydb_sub_task/
registry.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2026 ReifyDB
3
4use std::sync::Arc;
5
6use dashmap::DashMap;
7use reifydb_core::interface::catalog::task::TaskId;
8use reifydb_runtime::context::clock::Instant;
9
10use crate::task::ScheduledTask;
11
12#[derive(Debug, Clone)]
13pub struct TaskEntry {
14	pub task: Arc<ScheduledTask>,
15
16	pub next_execution: Instant,
17}
18
19pub type TaskRegistry = Arc<DashMap<TaskId, TaskEntry>>;
20
21#[derive(Debug, Clone)]
22pub struct TaskInfo {
23	pub id: TaskId,
24	pub name: String,
25	pub next_execution: Instant,
26}
27
28impl TaskInfo {
29	pub fn from_entry(id: TaskId, entry: &TaskEntry) -> Self {
30		Self {
31			id,
32			name: entry.task.name.clone(),
33			next_execution: entry.next_execution.clone(),
34		}
35	}
36}