use std::time::Duration;
use frame_core::component::{
ChildArgument, ChildSpec, ComponentId, ComponentMeta, ServiceCapability, SupervisionPolicy,
};
pub const PRESENCE_BYTECODE: &[u8] = include_bytes!("../component/graph_view_presence.beam");
pub const COMPONENT_PUBLISHER: &str = "frame.demo";
pub const COMPONENT_NAME: &str = "demo-graph";
pub const CONTRACT_ID: &str = "frame:graph-view@v1";
pub const PRESENCE_CHILD: &str = "presence";
pub const LIVENESS_MESSAGE: i64 = 0;
pub const STOP_MESSAGE: i64 = 2;
pub const NEWS_MESSAGE: i64 = 7;
const MAX_RESTARTS: usize = 3;
const RESTART_WINDOW: Duration = Duration::from_secs(30);
#[must_use]
pub fn component_id() -> ComponentId {
ComponentId::derive(COMPONENT_PUBLISHER, COMPONENT_NAME)
}
#[must_use]
pub fn component_meta() -> ComponentMeta {
ComponentMeta {
id: component_id(),
name: "GraphCanvas (GraphMother) — class-(b) client-native graph view".to_owned(),
version: "0.1.0".to_owned(),
requires: Vec::new(),
provides: vec![ServiceCapability {
id: CONTRACT_ID.to_owned(),
description: "graph view fragments under the frame:graph-view@v1 \
subscription contract, rendered client-natively"
.to_owned(),
}],
needs: Vec::new(),
actions: Vec::new(),
fragments: Vec::new(),
children: vec![ChildSpec {
name: PRESENCE_CHILD.to_owned(),
module: "graph_view_presence".to_owned(),
function: "run".to_owned(),
arguments: vec![ChildArgument::SupervisorPid],
liveness_message: LIVENESS_MESSAGE,
stop_message: STOP_MESSAGE,
}],
supervision: Some(SupervisionPolicy {
max_restarts: MAX_RESTARTS,
window: RESTART_WINDOW,
}),
}
}