query_runtime/observability/
task_identity.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
6#[serde(transparent)]
7pub struct RuntimeTaskId(String);
9
10impl RuntimeTaskId {
11 pub fn new(value: impl Into<String>) -> Self {
13 Self(value.into())
14 }
15
16 pub fn as_str(&self) -> &str {
18 &self.0
19 }
20}
21
22impl From<String> for RuntimeTaskId {
23 fn from(value: String) -> Self {
24 Self::new(value)
25 }
26}
27
28impl From<&str> for RuntimeTaskId {
29 fn from(value: &str) -> Self {
30 Self::new(value)
31 }
32}
33
34impl std::fmt::Display for RuntimeTaskId {
35 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 formatter.write_str(self.as_str())
37 }
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
41#[serde(transparent)]
42pub struct RuntimeAttemptId(u32);
44
45impl RuntimeAttemptId {
46 pub const fn new(value: u32) -> Self {
48 Self(value)
49 }
50}
51
52#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
53pub struct TaskAttemptId {
55 pub task_id: RuntimeTaskId,
57 pub(crate) attempt: RuntimeAttemptId,
58}
59
60impl TaskAttemptId {
61 pub const fn new(task_id: RuntimeTaskId, attempt: RuntimeAttemptId) -> Self {
63 Self { task_id, attempt }
64 }
65}