Skip to main content

PhotonBackend

Trait PhotonBackend 

Source
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 { ... }
}
Expand description

Backend for publish/subscribe delivery and checkpoint persistence.

Required Methods§

Source

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_id assigned by the underlying storage port.
  • Ordering and dedupe are per (topic_name, topic_key) partition, not global.
Source

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
Source

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
Source

fn registry(&self) -> &TopicRegistry

Inventory-discovered topic descriptors.

Source

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 None when no checkpoint exists.
Source

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_seq must not regress; coalesced writes may batch behind the scenes.

Provided Methods§

Source

fn telemetry_label(&self) -> &'static str

Stable telemetry label for ops metrics (e.g. "mem", "nats").

Source

fn capabilities(&self) -> StorageCapabilities

Adapter capabilities (replay window, get-by-id support, …).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§