use std::error::Error;
use async_trait::async_trait;
use crate::config::Config;
use crate::consumer::ConsumeAttempt;
use crate::transform::TransformAttempt;
#[async_trait]
pub trait ConsumeAttemptCreator: Send {
type Output: Send;
type TransformAttempt: TransformAttempt<ReturnType = Self::Output>;
type ConsumeAttempt: ConsumeAttempt<ConsumeVal = Self::Output>;
type ConsumeAttemptCreationError: Send + Error;
async fn new(config: std::sync::Arc<tokio::sync::Mutex<impl Config>>) -> Self
where
Self: Sized;
async fn create_new_attempt(
&mut self,
request: &Self::TransformAttempt,
) -> Result<Self::ConsumeAttempt, Self::ConsumeAttemptCreationError>;
async fn create_new_reattempt(
&mut self,
attempt_id: <Self::ConsumeAttempt as ConsumeAttempt>::Identifier,
error: <Self::ConsumeAttempt as ConsumeAttempt>::ReturnCtx,
) -> Result<Self::ConsumeAttempt, Self::ConsumeAttemptCreationError>;
}