pub struct NodeHeartbeat {
pub peer_id: PeerIdString,
pub status: NodeStatus,
pub available_storage: Bytes,
pub available_bandwidth: u64,
pub active_connections: u32,
pub timestamp: DateTime<Utc>,
}Expand description
Heartbeat message from node to coordinator.
Fields§
§peer_id: PeerIdStringNode’s peer ID.
status: NodeStatusCurrent node status.
available_storage: BytesAvailable storage (bytes).
available_bandwidth: u64Available bandwidth (bps).
active_connections: u32Number of active connections.
timestamp: DateTime<Utc>Timestamp of the heartbeat.
Implementations§
Source§impl NodeHeartbeat
impl NodeHeartbeat
Sourcepub fn new(peer_id: impl Into<String>, status: NodeStatus) -> Self
pub fn new(peer_id: impl Into<String>, status: NodeStatus) -> Self
Create a new heartbeat with current timestamp.
§Examples
use chie_shared::{NodeHeartbeat, NodeStatus};
// Create online heartbeat
let heartbeat = NodeHeartbeat::new("12D3KooWNode", NodeStatus::Online);
assert_eq!(heartbeat.peer_id, "12D3KooWNode");
assert_eq!(heartbeat.status, NodeStatus::Online);
assert_eq!(heartbeat.available_storage, 0);
// Create custom heartbeat with resources
let mut custom = NodeHeartbeat::new("12D3KooWOther", NodeStatus::Online);
custom.available_storage = 100 * 1024 * 1024 * 1024; // 100 GB
custom.available_bandwidth = 10_000_000; // 10 Mbps
custom.active_connections = 42;
assert_eq!(custom.active_connections, 42);Trait Implementations§
Source§impl Clone for NodeHeartbeat
impl Clone for NodeHeartbeat
Source§fn clone(&self) -> NodeHeartbeat
fn clone(&self) -> NodeHeartbeat
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NodeHeartbeat
impl Debug for NodeHeartbeat
Source§impl<'de> Deserialize<'de> for NodeHeartbeat
impl<'de> Deserialize<'de> for NodeHeartbeat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NodeHeartbeat
impl RefUnwindSafe for NodeHeartbeat
impl Send for NodeHeartbeat
impl Sync for NodeHeartbeat
impl Unpin for NodeHeartbeat
impl UnwindSafe for NodeHeartbeat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more