diff options
Diffstat (limited to 'exes/webhook/src/main.rs')
| -rw-r--r-- | exes/webhook/src/main.rs | 54 | 
1 files changed, 2 insertions, 52 deletions
diff --git a/exes/webhook/src/main.rs b/exes/webhook/src/main.rs index 0215e51..f531725 100644 --- a/exes/webhook/src/main.rs +++ b/exes/webhook/src/main.rs @@ -1,54 +1,4 @@ -mod config; -mod handler; -use std::{future::Future, pin::Pin}; - -use crate::{ -    config::WebhookConfig, -    handler::{handler::WebhookService, make_service::MakeSvc}, -}; -use hyper::Server; -use leash::{ignite, AnyhowResultFuture, Component}; -use shared::{config::Settings, log::info, nats_crate::Client}; -use tokio::sync::oneshot; - -#[derive(Clone, Copy)] -struct WebhookServer {} - -impl Component for WebhookServer { -    type Config = WebhookConfig; -    const SERVICE_NAME: &'static str = "webhook"; - -    fn start( -        &self, -        settings: Settings<Self::Config>, -        stop: oneshot::Receiver<()>, -    ) -> AnyhowResultFuture<()> { -        Box::pin(async move { -            info!("Starting server on {}", settings.server.listening_adress); - -            let bind = settings.server.listening_adress; -            let nats = -                Into::<Pin<Box<dyn Future<Output = anyhow::Result<Client>>>>>::into(settings.nats) -                    .await?; - -            let make_service = MakeSvc::new(WebhookService { -                config: settings.config, -                nats: nats.clone(), -            }); - -            let server = Server::bind(&bind).serve(make_service); - -            server.with_graceful_shutdown(async { -                stop.await.expect("should not fail"); -            }).await?; - -            Ok(()) -        }) -    } - -    fn new() -> Self { -        Self {} -    } -} +use leash::ignite; +use webhook::WebhookServer;  ignite!(WebhookServer);  | 
