pub trait PhotonBackend: Send + Sync {
// Required methods
fn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
topic_name: &'life1 str,
topic_key: Option<&'life2 str>,
actor_json: Value,
payload_json: Value,
) -> Pin<Box<dyn Future<Output = Result<String, PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn subscribe(
&self,
topic_name: String,
topic_key_filter: Option<String>,
after_seq: Option<i64>,
) -> Pin<Box<dyn Stream<Item = Result<Event, PhotonError>> + Send>>;
fn get_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn registry(&self) -> &TopicRegistry;
fn get_checkpoint_seq<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn set_checkpoint<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
last_seq: i64,
) -> Pin<Box<dyn Future<Output = Result<(), PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
// Provided methods
fn telemetry_label(&self) -> &'static str { ... }
fn capabilities(&self) -> StorageCapabilities { ... }
fn list_by_topic<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_topic_name: &'life1 str,
_topic_key: Option<&'life2 str>,
_after_seq: Option<i64>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn list_recent<'life0, 'async_trait>(
&'life0 self,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Backend for publish/subscribe delivery and checkpoint persistence.
Most hosts never implement this — use a storage adapter and the default
GenericPhotonBackend. Custom delivery example:
use std::sync::Arc;
use photon_backend::{BackendContext, PhotonBackend};
use photon_runtime::Photon;
let _photon = Photon::builder()
.backend_with_context(|ctx: BackendContext| {
// return Ok(Arc::new(MyBackend::new(ctx)) as Arc<dyn PhotonBackend>)
photon_backend::EmbeddedBackend::install_mem(ctx)
})
.auto_registry()
.build()?;Required Methods§
Sourcefn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
topic_name: &'life1 str,
topic_key: Option<&'life2 str>,
actor_json: Value,
payload_json: Value,
) -> Pin<Box<dyn Future<Output = Result<String, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
topic_name: &'life1 str,
topic_key: Option<&'life2 str>,
actor_json: Value,
payload_json: Value,
) -> Pin<Box<dyn Future<Output = Result<String, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Append an event and return its event id.
§Contract
- Returns the stable
event_idassigned by the underlying storage port. - Ordering and dedupe are per
(topic_name, topic_key)partition, not global.
Sourcefn subscribe(
&self,
topic_name: String,
topic_key_filter: Option<String>,
after_seq: Option<i64>,
) -> Pin<Box<dyn Stream<Item = Result<Event, PhotonError>> + Send>>
fn subscribe( &self, topic_name: String, topic_key_filter: Option<String>, after_seq: Option<i64>, ) -> Pin<Box<dyn Stream<Item = Result<Event, PhotonError>> + Send>>
Stream events for a topic partition, optionally replaying after after_seq.
§Contract
- Same semantics as
crate::storage::StoragePort::subscribe.
Sourcefn get_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load a single event by id.
§Contract
- Returns
Nonewhen unknown or truncated; see backendBackendCapabilities.
Sourcefn registry(&self) -> &TopicRegistry
fn registry(&self) -> &TopicRegistry
Inventory-discovered topic descriptors.
Sourcefn get_checkpoint_seq<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn get_checkpoint_seq<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Load the last committed checkpoint seq for a subscription partition.
§Contract
- Returns
Nonewhen no checkpoint exists.
Sourcefn set_checkpoint<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
last_seq: i64,
) -> Pin<Box<dyn Future<Output = Result<(), PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn set_checkpoint<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
subscription_name: &'life1 str,
topic_name: &'life2 str,
topic_key: Option<&'life3 str>,
last_seq: i64,
) -> Pin<Box<dyn Future<Output = Result<(), PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Persist the high-water checkpoint seq for a subscription partition.
§Contract
last_seqmust not regress; coalesced writes may batch behind the scenes.
Provided Methods§
Sourcefn telemetry_label(&self) -> &'static str
fn telemetry_label(&self) -> &'static str
Stable telemetry label for ops metrics (e.g. "mem", "nats").
Sourcefn capabilities(&self) -> StorageCapabilities
fn capabilities(&self) -> StorageCapabilities
Adapter capabilities (replay window, get-by-id support, …).
Sourcefn list_by_topic<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_topic_name: &'life1 str,
_topic_key: Option<&'life2 str>,
_after_seq: Option<i64>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn list_by_topic<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_topic_name: &'life1 str,
_topic_key: Option<&'life2 str>,
_after_seq: Option<i64>,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Bounded page of events for one topic (ops browse).
Default returns empty when the adapter does not support listing.
Sourcefn list_recent<'life0, 'async_trait>(
&'life0 self,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list_recent<'life0, 'async_trait>(
&'life0 self,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, PhotonError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Bounded cross-topic page of newest events (ops browse).
Default returns empty when the adapter does not support listing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".