use async_trait::async_trait;
use tokio::sync::{mpsc::Sender, oneshot};
use vixen_core::Filters;
use yellowstone_grpc_proto::{geyser::SubscribeUpdate, tonic};
#[derive(Debug)]
pub enum SourceExitStatus {
ReceiverDropped,
Completed,
StreamEnded,
StreamError {
code: tonic::Code,
message: String,
},
Error(String),
}
#[async_trait]
pub trait SourceTrait: std::fmt::Debug + Send + Sync + 'static {
type Config: serde::de::DeserializeOwned + clap::Args + std::fmt::Debug;
fn new(config: Self::Config, filters: Filters) -> Self;
async fn connect(
&self,
tx: Sender<Result<SubscribeUpdate, tonic::Status>>,
status_tx: oneshot::Sender<SourceExitStatus>,
) -> Result<(), crate::Error>;
}