/
oiwn
/
capp-rs
Обзор
Документация
Войти
/
oiwn
/
capp-rs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
capp-queue/src/queue.rs
30 строк
1 KB
oiwn
fix fmt
02 мар 2025, 20:31
02 мар 2025, 20:31
8dd677a
Код
Авторство
О чём код?
//! This module provides a trait for interacting with task storage. //! The storage allows tasks to be pushed to and popped from a queue, //! and also allows tasks to be set and retrieved by their UUID. use async_trait::async_trait; use serde::{Serialize, de::DeserializeOwned}; use std::{fmt::Debug, sync::Arc}; use super::TaskQueueError; use crate::task::{Task, TaskId}; #[async_trait] pub trait TaskQueue<Data> where Data: Debug + Clone + Serialize + DeserializeOwned + Send + Sync + 'static, { async fn push(&self, task: &Task<Data>) -> Result<(), TaskQueueError>; async fn pop(&self) -> Result<Task<Data>, TaskQueueError>; async fn ack(&self, task_id: &TaskId) -> Result<(), TaskQueueError>; async fn nack(&self, task: &Task<Data>) -> Result<(), TaskQueueError>; async fn set(&self, task: &Task<Data>) -> Result<(), TaskQueueError>; } pub type AbstractTaskQueue<D> = Arc<dyn TaskQueue<D> + Send + Sync>; // Trait used for round-robin queues pub trait HasTagKey { type TagValue: ToString + PartialEq; fn get_tag_value(&self) -> Self::TagValue; }