fabaccess-bffh/runtime/console/src/event.rs

67 lines
1.7 KiB
Rust
Raw Normal View History

2022-06-21 19:11:57 +02:00
use crate::stats;
use console_api::resources;
use std::sync::Arc;
2022-06-21 22:23:55 +02:00
use tracing::span;
2022-06-21 16:20:44 +02:00
use tracing_core::Metadata;
pub(crate) enum Event {
Metadata(&'static Metadata<'static>),
2022-06-21 19:11:57 +02:00
Spawn {
2022-06-21 22:23:55 +02:00
id: span::Id,
2022-06-21 19:11:57 +02:00
metadata: &'static Metadata<'static>,
stats: Arc<stats::TaskStats>,
fields: Vec<console_api::Field>,
location: Option<console_api::Location>,
},
Resource {
2022-06-21 22:23:55 +02:00
id: span::Id,
parent_id: Option<span::Id>,
2022-06-21 19:11:57 +02:00
metadata: &'static Metadata<'static>,
concrete_type: String,
kind: resources::resource::Kind,
location: Option<console_api::Location>,
is_internal: bool,
stats: Arc<stats::ResourceStats>,
},
PollOp {
metadata: &'static Metadata<'static>,
2022-06-21 22:23:55 +02:00
resource_id: span::Id,
2022-06-21 19:11:57 +02:00
op_name: String,
2022-06-21 22:23:55 +02:00
async_op_id: span::Id,
task_id: span::Id,
2022-06-21 19:11:57 +02:00
is_ready: bool,
},
AsyncResourceOp {
2022-06-21 22:23:55 +02:00
id: span::Id,
parent_id: Option<span::Id>,
resource_id: span::Id,
2022-06-21 19:11:57 +02:00
metadata: &'static Metadata<'static>,
source: String,
stats: Arc<stats::AsyncOpStats>,
},
2022-06-21 16:20:44 +02:00
}
2022-06-21 22:23:55 +02:00
#[derive(Clone, Debug, Copy)]
pub(crate) enum WakeOp {
Wake { self_wake: bool },
WakeByRef { self_wake: bool },
Clone,
Drop,
}
impl WakeOp {
/// Returns `true` if `self` is a `Wake` or `WakeByRef` event.
pub(crate) fn is_wake(self) -> bool {
matches!(self, Self::Wake { .. } | Self::WakeByRef { .. })
}
pub(crate) fn self_wake(self, self_wake: bool) -> Self {
match self {
Self::Wake { .. } => Self::Wake { self_wake },
Self::WakeByRef { .. } => Self::WakeByRef { self_wake },
x => x,
}
}
}