From dc4c448e597b08cba4c79c194b0c1aa517daab29 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 15 Jul 2024 13:28:00 +0200 Subject: core: rename EventSys to EventEmitter --- p2p/src/connection.rs | 8 ++++---- p2p/src/monitor/mod.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'p2p/src') diff --git a/p2p/src/connection.rs b/p2p/src/connection.rs index 52190a8..c1a7a8c 100644 --- a/p2p/src/connection.rs +++ b/p2p/src/connection.rs @@ -4,7 +4,7 @@ use async_channel::Sender; use bincode::Encode; use karyon_core::{ - event::{EventListener, EventSys}, + event::{EventEmitter, EventListener}, util::encode, }; @@ -36,8 +36,8 @@ pub struct Connection { pub(crate) direction: ConnDirection, conn: Conn, disconnect_signal: Sender>, - /// `EventSys` responsible for sending events to the registered protocols. - protocol_events: Arc>, + /// `EventEmitter` responsible for sending events to the registered protocols. + protocol_events: Arc>, pub(crate) remote_endpoint: Endpoint, listeners: HashMap>, } @@ -52,7 +52,7 @@ impl Connection { Self { conn, direction, - protocol_events: EventSys::new(), + protocol_events: EventEmitter::new(), disconnect_signal: signal, remote_endpoint, listeners: HashMap::new(), diff --git a/p2p/src/monitor/mod.rs b/p2p/src/monitor/mod.rs index 86db23e..cbd492a 100644 --- a/p2p/src/monitor/mod.rs +++ b/p2p/src/monitor/mod.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use log::error; -use karyon_core::event::{EventListener, EventSys, EventValue, EventValueTopic}; +use karyon_core::event::{EventEmitter, EventListener, EventValue, EventValueTopic}; use karyon_net::Endpoint; @@ -47,7 +47,7 @@ use crate::{Config, PeerID}; /// }; /// ``` pub struct Monitor { - event_sys: Arc>, + event_emitter: Arc>, config: Arc, } @@ -55,7 +55,7 @@ impl Monitor { /// Creates a new Monitor pub(crate) fn new(config: Arc) -> Self { Self { - event_sys: EventSys::new(), + event_emitter: EventEmitter::new(), config, } } @@ -64,7 +64,7 @@ impl Monitor { pub(crate) async fn notify(&self, event: E) { if self.config.enable_monitor { let event = event.to_struct(); - if let Err(err) = self.event_sys.emit(&event).await { + if let Err(err) = self.event_emitter.emit(&event).await { error!("Failed to notify monitor event {:?}: {err}", event); } } @@ -75,7 +75,7 @@ impl Monitor { where E: Clone + EventValue + EventValueTopic, { - self.event_sys.register(&E::topic()).await + self.event_emitter.register(&E::topic()).await } } -- cgit v1.2.3