From adff5b2edf2498893852dcb987cd1b43bc06633e Mon Sep 17 00:00:00 2001 From: pxp9 <48651252+pxp9@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:52:54 +0200 Subject: [PATCH] improving worker API --- fang/src/asynk/async_worker.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fang/src/asynk/async_worker.rs b/fang/src/asynk/async_worker.rs index a0d3d42..e9f1360 100644 --- a/fang/src/asynk/async_worker.rs +++ b/fang/src/asynk/async_worker.rs @@ -29,7 +29,7 @@ impl AsyncWorker where AQueue: AsyncQueueable + Clone + Sync + 'static, { - async fn run(&mut self, task: &Task, runnable: &dyn AsyncRunnable) -> Result<(), FangError> { + async fn run(&self, task: &Task, runnable: &dyn AsyncRunnable) -> Result<(), FangError> { let result = runnable.run(&self.queue).await; match result { @@ -52,7 +52,7 @@ where } async fn finalize_task( - &mut self, + &self, task: &Task, result: &Result<(), FangError>, ) -> Result<(), FangError> { @@ -143,11 +143,7 @@ pub struct AsyncWorkerTest<'a> { #[cfg(test)] impl<'a> AsyncWorkerTest<'a> { - pub async fn run( - &mut self, - task: &Task, - runnable: &dyn AsyncRunnable, - ) -> Result<(), FangError> { + pub async fn run(&self, task: &Task, runnable: &dyn AsyncRunnable) -> Result<(), FangError> { let result = runnable.run(self.queue).await; match result { @@ -170,7 +166,7 @@ impl<'a> AsyncWorkerTest<'a> { } async fn finalize_task( - &mut self, + &self, task: &Task, result: &Result<(), FangError>, ) -> Result<(), FangError> { @@ -393,7 +389,7 @@ mod async_worker_tests { let task = insert_task(&mut test, &actual_task).await; let id = task.id; - let mut worker = AsyncWorkerTest::builder() + let worker = AsyncWorkerTest::builder() .queue(&mut test as &mut dyn AsyncQueueable) .retention_mode(RetentionMode::KeepAll) .build(); @@ -484,7 +480,7 @@ mod async_worker_tests { let task = insert_task(&mut test, &failed_task).await; let id = task.id; - let mut worker = AsyncWorkerTest::builder() + let worker = AsyncWorkerTest::builder() .queue(&mut test as &mut dyn AsyncQueueable) .retention_mode(RetentionMode::KeepAll) .build();