Use slices where possible

This commit is contained in:
Rafael Caricio 2023-03-11 22:33:25 +01:00
parent 89df4cfe8e
commit eed21d265d
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947
4 changed files with 7 additions and 7 deletions

View file

@ -23,12 +23,12 @@ impl Default for RetentionMode {
}
}
pub use queue::Queue;
pub use runnable::BackgroundTask;
pub use store::{PgTaskStore, TaskStore};
pub use task::{CurrentTask, Task, TaskId, TaskState};
pub use worker_pool::WorkerPool;
pub use worker::Worker;
pub use queue::Queue;
pub use worker_pool::WorkerPool;
pub mod errors;
mod queries;

View file

@ -65,7 +65,7 @@ impl Task {
pub(crate) async fn fetch_next_pending(
connection: &mut AsyncPgConnection,
queue_name: &str,
task_names: &Vec<String>,
task_names: &[String],
) -> Option<Task> {
backie_tasks::table
.filter(backie_tasks::task_name.eq_any(task_names))

View file

@ -22,7 +22,7 @@ impl TaskStore for PgTaskStore {
async fn pull_next_task(
&self,
queue_name: &str,
task_names: &Vec<String>,
task_names: &[String],
) -> Result<Option<Task>, AsyncQueueError> {
let mut connection = self
.pool
@ -114,7 +114,7 @@ pub mod test_store {
async fn pull_next_task(
&self,
queue_name: &str,
task_names: &Vec<String>,
task_names: &[String],
) -> Result<Option<Task>, AsyncQueueError> {
let mut tasks = self.tasks.lock().await;
let mut next_task = None;
@ -201,7 +201,7 @@ pub trait TaskStore: Clone + Send + Sync + 'static {
async fn pull_next_task(
&self,
queue_name: &str,
task_names: &Vec<String>,
task_names: &[String],
) -> Result<Option<Task>, AsyncQueueError>;
async fn create_task(&self, new_task: NewTask) -> Result<Task, AsyncQueueError>;
async fn set_task_state(&self, id: TaskId, state: TaskState) -> Result<(), AsyncQueueError>;

View file

@ -91,7 +91,7 @@ where
}
pub(crate) async fn run_tasks(&mut self) -> Result<(), BackieError> {
let registered_task_names = self.task_registry.keys().cloned().collect();
let registered_task_names = self.task_registry.keys().cloned().collect::<Vec<_>>();
loop {
// Check if has to stop before pulling next task
if let Some(ref shutdown) = self.shutdown {