refactor: extract messages and handlers modules from webhook-actor
All checks were successful
Rust / build (push) Successful in 1m54s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful

This commit is contained in:
Paul Campbell 2024-07-19 07:48:36 +01:00
parent ba67b1ebcb
commit 8f95ae0058
5 changed files with 22 additions and 12 deletions

View file

@ -7,6 +7,7 @@ repository = { workspace = true }
description = "webhook actor for git-next, the trunk-based development manager"
[dependencies]
git-next-actor-macros = { workspace = true }
git-next-config = { workspace = true }
git-next-repo-actor = { workspace = true }

View file

@ -0,0 +1 @@
mod shutdown_webhook;

View file

@ -0,0 +1,13 @@
//
use actix::prelude::*;
use crate::{ShutdownWebhook, WebhookActor};
impl Handler<ShutdownWebhook> for WebhookActor {
type Result = ();
fn handle(&mut self, _msg: ShutdownWebhook, ctx: &mut Self::Context) -> Self::Result {
self.spawn_handle.take();
ctx.stop();
}
}

View file

@ -1,10 +1,13 @@
//
use actix::prelude::*;
mod handlers;
pub mod messages;
mod router;
mod server;
use git_next_repo_actor::messages::WebhookNotification;
pub use messages::ShutdownWebhook;
use std::net::SocketAddr;
@ -40,15 +43,3 @@ impl Actor for WebhookActor {
self.spawn_handle.replace(spawn_handle);
}
}
#[derive(Debug, Message)]
#[rtype(result = "()")]
pub struct ShutdownWebhook;
impl Handler<ShutdownWebhook> for WebhookActor {
type Result = ();
fn handle(&mut self, _msg: ShutdownWebhook, ctx: &mut Self::Context) -> Self::Result {
self.spawn_handle.take();
ctx.stop();
}
}

View file

@ -0,0 +1,4 @@
//
use git_next_actor_macros::message;
message!(ShutdownWebhook: "Request to shutdown the Webhook actor");