pub trait TaskStorage: Send + Sync {
// Required methods
fn register(
&self,
pid: u32,
record: &TaskRecord,
) -> Result<(), RegistryError>;
fn mark_completed(
&self,
pid: u32,
result: Option<String>,
exit_code: Option<i32>,
completed_at: DateTime<Utc>,
) -> Result<(), RegistryError>;
fn entries(&self) -> Result<Vec<RegistryEntry>, RegistryError>;
fn sweep_stale_entries<F, G>(
&self,
now: DateTime<Utc>,
is_process_alive: F,
terminate_process: &G,
) -> Result<Vec<CleanupEvent>, RegistryError>
where F: Fn(u32) -> bool,
G: Fn(u32) -> Result<(), String>;
fn get_completed_unread_tasks(
&self,
) -> Result<Vec<(u32, TaskRecord)>, RegistryError>;
fn has_running_tasks(
&self,
filter: Option<&ProcessTreeInfo>,
) -> Result<bool, RegistryError>;
}Expand description
任务存储的统一接口 提供跨进程(SharedMemory)和进程内(InProcess)两种实现
Required Methods§
Sourcefn register(&self, pid: u32, record: &TaskRecord) -> Result<(), RegistryError>
fn register(&self, pid: u32, record: &TaskRecord) -> Result<(), RegistryError>
注册新任务
Sourcefn mark_completed(
&self,
pid: u32,
result: Option<String>,
exit_code: Option<i32>,
completed_at: DateTime<Utc>,
) -> Result<(), RegistryError>
fn mark_completed( &self, pid: u32, result: Option<String>, exit_code: Option<i32>, completed_at: DateTime<Utc>, ) -> Result<(), RegistryError>
标记任务完成
Sourcefn entries(&self) -> Result<Vec<RegistryEntry>, RegistryError>
fn entries(&self) -> Result<Vec<RegistryEntry>, RegistryError>
获取所有任务条目
Sourcefn sweep_stale_entries<F, G>(
&self,
now: DateTime<Utc>,
is_process_alive: F,
terminate_process: &G,
) -> Result<Vec<CleanupEvent>, RegistryError>
fn sweep_stale_entries<F, G>( &self, now: DateTime<Utc>, is_process_alive: F, terminate_process: &G, ) -> Result<Vec<CleanupEvent>, RegistryError>
清理过期任务
Sourcefn get_completed_unread_tasks(
&self,
) -> Result<Vec<(u32, TaskRecord)>, RegistryError>
fn get_completed_unread_tasks( &self, ) -> Result<Vec<(u32, TaskRecord)>, RegistryError>
获取已完成但未读的任务
Sourcefn has_running_tasks(
&self,
filter: Option<&ProcessTreeInfo>,
) -> Result<bool, RegistryError>
fn has_running_tasks( &self, filter: Option<&ProcessTreeInfo>, ) -> Result<bool, RegistryError>
检查是否有运行中的任务
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.