Use slices where possible
This commit is contained in:
parent
89df4cfe8e
commit
eed21d265d
4 changed files with 7 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue