All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m45s
50 lines
1.4 KiB
Rust
Executable File
50 lines
1.4 KiB
Rust
Executable File
use crate::message_broker::MessageBroker;
|
|
use std::sync::atomic::Ordering;
|
|
use std::sync::Arc;
|
|
use std::thread;
|
|
use std::time::Duration;
|
|
|
|
use crate::db::ConnectionPool;
|
|
use super::base::{BaseWorker, Worker, WorkerState};
|
|
|
|
macro_rules! define_simple_worker {
|
|
($name:ident) => {
|
|
pub struct $name {
|
|
base: BaseWorker,
|
|
}
|
|
|
|
impl $name {
|
|
pub fn new(pool: ConnectionPool, broker: MessageBroker) -> Self {
|
|
Self {
|
|
base: BaseWorker::new(stringify!($name), pool, broker),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Worker for $name {
|
|
fn start_worker_thread(&mut self) {
|
|
self.base
|
|
.start_worker_with_loop(|state: Arc<WorkerState>| {
|
|
// Einfache Dummy-Schleife, bis echte Logik portiert ist
|
|
while state.running_worker.load(Ordering::Relaxed) {
|
|
if let Ok(mut step) = state.current_step.lock() {
|
|
*step = format!("{}: idle", stringify!($name));
|
|
}
|
|
thread::sleep(Duration::from_secs(5));
|
|
}
|
|
});
|
|
}
|
|
|
|
fn stop_worker_thread(&mut self) {
|
|
self.base.stop_worker();
|
|
}
|
|
|
|
fn enable_watchdog(&mut self) {
|
|
self.base.start_watchdog();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
|