use std::pin::Pin;
use async_trait::async_trait;
use futures::stream::Stream;
use serde_json::Value;
use crate::backend::BackendCapabilities;
use crate::error::Result;
use crate::models::Event;
use crate::registry::TopicRegistry;
#[async_trait]
pub trait PhotonBackend: Send + Sync {
fn telemetry_label(&self) -> &'static str {
"custom"
}
fn capabilities(&self) -> BackendCapabilities {
BackendCapabilities::mem()
}
async fn publish(
&self,
topic_name: &str,
topic_key: Option<&str>,
actor_json: Value,
payload_json: Value,
) -> Result<String>;
fn subscribe(
&self,
topic_name: String,
topic_key_filter: Option<String>,
after_seq: Option<i64>,
) -> Pin<Box<dyn Stream<Item = Result<Event>> + Send>>;
async fn get_event(&self, event_id: &str) -> Result<Option<Event>>;
fn registry(&self) -> &TopicRegistry;
async fn get_checkpoint_seq(
&self,
subscription_name: &str,
topic_name: &str,
topic_key: Option<&str>,
) -> Result<Option<i64>>;
async fn set_checkpoint(
&self,
subscription_name: &str,
topic_name: &str,
topic_key: Option<&str>,
last_seq: i64,
) -> Result<()>;
}