chore: remove dummy service

This commit is contained in:
2025-08-26 19:16:11 -05:00
parent 87100a57d5
commit 5018ad0d31
3 changed files with 10 additions and 48 deletions

View File

@@ -6,7 +6,7 @@ use tracing_subscriber::{EnvFilter, FmtSubscriber};
use crate::bot::{Data, age};
use crate::config::Config;
use crate::services::manager::ServiceManager;
use crate::services::{ServiceResult, bot::BotService, dummy::DummyService, run_service};
use crate::services::{ServiceResult, bot::BotService, run_service};
use figment::{Figment, providers::Env};
mod bot;
@@ -42,13 +42,21 @@ async fn main() {
// Configure the client with your Discord bot token in the environment.
let intents = GatewayIntents::non_privileged();
let bot_target_guild = config.bot_target_guild;
let framework = poise::Framework::builder()
.options(poise::FrameworkOptions {
commands: vec![age()],
..Default::default()
})
.setup(|ctx, _ready, framework| {
.setup(move |ctx, _ready, framework| {
Box::pin(async move {
poise::builtins::register_in_guild(
ctx,
&framework.options().commands,
bot_target_guild.into(),
)
.await?;
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {})
})
@@ -68,13 +76,10 @@ async fn main() {
// Create and add services
let bot_service = Box::new(BotService::new(client));
let dummy_service = Box::new(DummyService::new("background"));
let bot_handle = tokio::spawn(run_service(bot_service, service_manager.subscribe()));
let dummy_handle = tokio::spawn(run_service(dummy_service, service_manager.subscribe()));
service_manager.add_service("bot".to_string(), bot_handle);
service_manager.add_service("background".to_string(), dummy_handle);
// Set up CTRL+C signal handling
let ctrl_c = async {

View File

@@ -1,42 +0,0 @@
use super::Service;
use std::time::Duration;
use tracing::{error, info};
/// Dummy service implementation for demonstration
pub struct DummyService {
name: &'static str,
}
impl DummyService {
pub fn new(name: &'static str) -> Self {
Self { name }
}
}
#[async_trait::async_trait]
impl Service for DummyService {
fn name(&self) -> &'static str {
self.name
}
async fn run(&mut self) -> Result<(), anyhow::Error> {
let mut counter = 0;
loop {
tokio::time::sleep(Duration::from_secs(10)).await;
counter += 1;
info!(service = self.name, "Service heartbeat ({counter})");
// Simulate service failure after 60 seconds for demo
if counter >= 6 {
error!(service = self.name, "Service encountered an error");
return Err(anyhow::anyhow!("Service error"));
}
}
}
async fn shutdown(&mut self) -> Result<(), anyhow::Error> {
// Simulate cleanup work
tokio::time::sleep(Duration::from_millis(6000)).await;
Ok(())
}
}

View File

@@ -2,7 +2,6 @@ use tokio::sync::broadcast;
use tracing::{error, info, warn};
pub mod bot;
pub mod dummy;
pub mod manager;
#[derive(Debug)]