73 lines
1.9 KiB
Rust
73 lines
1.9 KiB
Rust
use clusterflux_core::{
|
|
ArtifactId, NodeId, ProcessId, ProjectId, TaskInstanceId, TenantId, VfsPath,
|
|
};
|
|
|
|
pub(super) type TaskControlKey = (TenantId, ProjectId, ProcessId, NodeId, TaskInstanceId);
|
|
pub(super) type TaskRestartKey = (TenantId, ProjectId, ProcessId, TaskInstanceId);
|
|
pub(super) type TaskAssignmentKey = (TenantId, ProjectId, NodeId);
|
|
pub(super) type PanelStopKey = (TenantId, ProjectId, ProcessId);
|
|
pub(super) type EnrollmentGrantKey = (TenantId, ProjectId, String);
|
|
pub(super) type ProcessControlKey = (TenantId, ProjectId, ProcessId);
|
|
|
|
pub(super) fn task_control_key(
|
|
tenant: &TenantId,
|
|
project: &ProjectId,
|
|
process: &ProcessId,
|
|
node: &NodeId,
|
|
task: &TaskInstanceId,
|
|
) -> TaskControlKey {
|
|
(
|
|
tenant.clone(),
|
|
project.clone(),
|
|
process.clone(),
|
|
node.clone(),
|
|
task.clone(),
|
|
)
|
|
}
|
|
|
|
pub(super) fn task_restart_key(
|
|
tenant: &TenantId,
|
|
project: &ProjectId,
|
|
process: &ProcessId,
|
|
task: &TaskInstanceId,
|
|
) -> TaskRestartKey {
|
|
(
|
|
tenant.clone(),
|
|
project.clone(),
|
|
process.clone(),
|
|
task.clone(),
|
|
)
|
|
}
|
|
|
|
pub(super) fn process_control_key(
|
|
tenant: &TenantId,
|
|
project: &ProjectId,
|
|
process: &ProcessId,
|
|
) -> ProcessControlKey {
|
|
(tenant.clone(), project.clone(), process.clone())
|
|
}
|
|
|
|
pub(super) fn panel_stop_key(
|
|
tenant: &TenantId,
|
|
project: &ProjectId,
|
|
process: &ProcessId,
|
|
) -> PanelStopKey {
|
|
(tenant.clone(), project.clone(), process.clone())
|
|
}
|
|
|
|
pub(super) fn enrollment_grant_key(
|
|
tenant: &TenantId,
|
|
project: &ProjectId,
|
|
grant: &str,
|
|
) -> EnrollmentGrantKey {
|
|
(tenant.clone(), project.clone(), grant.to_owned())
|
|
}
|
|
|
|
pub(super) fn artifact_id_from_path(path: &VfsPath) -> ArtifactId {
|
|
let value = path
|
|
.as_str()
|
|
.strip_prefix("/vfs/artifacts/")
|
|
.unwrap_or(path.as_str())
|
|
.replace('/', ":");
|
|
ArtifactId::new(value)
|
|
}
|