Skip to main content

Photon

Struct Photon 

Source
pub struct Photon { /* private fields */ }
Expand description

Main Photon runtime handle.

Implementations§

Source§

impl Photon

Source

pub fn builder() -> PhotonBuilder

Start building a Photon runtime instance.

Source

pub fn backend_label(&self) -> &'static str

Telemetry label for the installed backend.

Source

pub async fn admin_snapshot(&self) -> Result<AdminSnapshot>

Compose a read-only ops introspection snapshot for host admin UIs.

Aggregates the topic catalog, handler inventory, backend capabilities, and checkpoint cursors for inventory-registered handlers. Does not touch publish/subscribe hot paths.

§Errors

Returns an error if a checkpoint load fails.

Source

pub async fn publish( &self, topic_name: &str, topic_key: Option<&str>, actor_json: Value, payload_json: Value, ) -> Result<String>

Publish a single event to a topic.

§Errors

Returns an error if the operation fails.

Source

pub fn subscribe( &self, topic_name: &str, topic_key_filter: Option<&str>, after_seq: Option<i64>, ) -> Pin<Box<dyn Stream<Item = Result<Event>> + Send>>

Subscribe to topic events as a stream.

For typed topics, prefer TopicType::subscribe(opts) or the #[subscribe] macro. Runnable walkthrough: cargo run -p uf-photon --example manual_subscribe --features runtime,mem.

§Example
use futures::StreamExt;
use photon_runtime::{configure, default, Photon};

configure(Photon::builder().auto_registry().build()?);
let photon = default().expect("configure first");
let mut stream = photon.subscribe("my.topic", None, None);
if let Some(result) = stream.next().await {
    let _event = result?;
}
Source

pub fn subscribe_consumer_group( &self, topic_name: &str, shard_ids: &[u32], after_seq_by_shard: HashMap<u32, Option<i64>>, ) -> Pin<Box<dyn Stream<Item = Result<Event>> + Send>>

Subscribe to assigned virtual shards for a consumer group (multiplexed stream).

Source

pub async fn get_event(&self, event_id: &str) -> Result<Option<Event>>

Load a specific event by ID.

§Errors

Returns an error if the operation fails.

Source

pub fn registry(&self) -> &TopicRegistry

Return the registered topic catalog.

Source

pub async fn get_checkpoint_seq( &self, subscription_name: &str, topic_name: &str, topic_key: Option<&str>, ) -> Result<Option<i64>>

Read the last checkpoint sequence for a subscription/topic pair.

§Errors

Returns an error if the operation fails.

Source

pub async fn set_checkpoint( &self, subscription_name: &str, topic_name: &str, topic_key: Option<&str>, last_seq: i64, ) -> Result<()>

Persist an updated checkpoint sequence for a subscription/topic pair.

§Errors

Returns an error if the operation fails.

Source

pub const fn runtime(&self) -> &PhotonRuntimeState

Shared tailer / executor services.

Source

pub async fn reclaim_transport(&self) -> Result<Vec<ReclaimReport>>

Reclaim transport log rows past the safe watermark (headless ops entry point).

§Errors

Returns an error if the operation fails.

Source

pub fn start_executor(&self, identity: Arc<dyn IdentityFactory>) -> Result<()>

Start inventory-registered #[photon::subscribe] handlers.

Requires an IdentityFactory (e.g. photon_core::JsonIdentityFactory) for actor resolution. Optionally call configure so convenience Type::publish() helpers work.

§Example
use std::sync::Arc;

use photon_core::JsonIdentityFactory;
use photon_runtime::Photon;

let photon = Photon::builder().auto_registry().build()?;
photon.start_executor(Arc::new(JsonIdentityFactory))?;
photon.shutdown_executor();
photon.join_executor().await;
§Errors

Returns an error if the executor was already started on this runtime.

Source

pub fn shutdown_executor(&self)

Signal handler loops to stop accepting new events.

§Contract

Idempotent. Pair with Self::join_executor to await in-flight work.

Source

pub async fn join_executor(&self)

Await handler loops and in-flight dispatches after Self::shutdown_executor.

§Contract

Safe when the executor was never started. Restart requires a new Photon build.

Trait Implementations§

Source§

impl Clone for Photon

Source§

fn clone(&self) -> Photon

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more