Skip to content

Commit

Permalink
feat(server): add local ShutdownEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 6, 2024
1 parent 503371d commit 3f55760
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/messages/events/local/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
pub mod error;
pub mod shutdown;

pub use error::ErrorEvent;
pub use shutdown::ShutdownEvent;

use super::event::{EventContext, OnEvent};

#[derive(Debug)]
pub enum LocalEvent {
Error(ErrorEvent),
Shutdown(ShutdownEvent),
}

impl OnEvent for LocalEvent {
fn on_event(self, ctx: &mut EventContext) -> crate::Result<()> {
match self {
Self::Error(e) => e.on_event(ctx),
Self::Shutdown(e) => e.on_event(ctx),
}
}
}
12 changes: 12 additions & 0 deletions src/messages/events/local/shutdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::messages::events::event::{EventContext, OnEvent};

#[derive(Debug, Default)]
pub struct ShutdownEvent;

impl OnEvent for ShutdownEvent {
fn on_event(self, ctx: &mut EventContext) -> crate::Result<()> {
ctx.cord.shutdown();

Ok(())
}
}

0 comments on commit 3f55760

Please sign in to comment.