Skip to main content

ChannelHandle

Struct ChannelHandle 

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

Cloneable handle for interacting with a channel actor process.

Implementations§

Source§

impl ChannelHandle

Source

pub fn new(config: ChannelConfig) -> Self

Creates an ephemeral handle backed by a real supervised channel actor on the shared default supervisor.

The actor process is spawned lazily on first use; a scheduler failure is surfaced as a LiminalError from the first operation, not a panic.

Source

pub fn with_supervisor( config: ChannelConfig, supervisor: ChannelSupervisor, ) -> Self

Creates an ephemeral handle bound to an explicit supervisor (isolation for the registry and tests).

Source

pub fn new_durable( config: ChannelConfig, store: Arc<dyn DurableStore>, ) -> Result<Self, LiminalError>

Creates a durable handle that persists every accepted publish to store before fanning it out to subscribers.

§Errors

Returns LiminalError::PublishFailed when the durable channel cannot be initialized over store.

Source

pub fn new_durable_with_supervisor( config: ChannelConfig, store: Arc<dyn DurableStore>, supervisor: ChannelSupervisor, ) -> Result<Self, LiminalError>

Creates a durable handle bound to an explicit supervisor.

Used by the standalone server so every channel — durable or ephemeral — shares ONE (optionally clustered) supervisor and thus one scheduler, which is the precondition for cross-node delivery (SRV-005): a subscriber pid joined to a channel’s distributed process group must live on the same scheduler that owns the distribution links.

§Errors

Returns LiminalError::PublishFailed when the durable channel cannot be initialized over store.

Source

pub const fn config(&self) -> &ChannelConfig

Returns the channel configuration used to create this handle.

Source

pub fn publish<Payload>(&self, payload: Payload) -> Result<(), LiminalError>
where Payload: AsRef<[u8]>,

Publishes a payload to the channel with the default publisher identity.

§Errors

Returns a LiminalError when the channel cannot accept the payload or the schema rejects it.

Source

pub fn publish_from<Payload>( &self, publisher_id: impl Into<PublisherId>, payload: Payload, ) -> Result<(), LiminalError>
where Payload: AsRef<[u8]>,

Publishes a payload with an explicit publisher identity.

§Errors

Returns a LiminalError when the channel cannot accept the payload or the schema rejects it.

Source

pub fn publish_with_context<Payload>( &self, payload: Payload, publisher_id: PublisherId, causal_context: Option<CausalContext>, ) -> Result<(), LiminalError>
where Payload: AsRef<[u8]>,

Publishes a payload with explicit publisher and causal metadata.

§Errors

Returns a LiminalError when the channel cannot accept the payload or the schema rejects it.

Source

pub fn publish_with_delivery<Payload>( &self, payload: Payload, publisher_id: PublisherId, causal_context: Option<CausalContext>, ) -> Result<ChannelDelivery, LiminalError>
where Payload: AsRef<[u8]>,

Publishes a payload and reports a genuine delivery ack.

Returns a ChannelDelivery whose delivered_count is the number of local subscribers the message was actually delivered to. A caller that needs to know the message was ACCEPTED by a subscriber (not merely buffered/published) inspects ChannelDelivery::is_delivered. This is the channel-library half of the 13-L1 delivery-ack signal; the publish-without- delivery methods stay unchanged for existing callers.

§Errors

Returns a LiminalError when the channel cannot accept the payload or the schema rejects it.

Source

pub fn current_schema_id(&self) -> Result<SchemaId, LiminalError>

Returns the schema version currently owned by the channel actor.

§Errors

Returns a LiminalError when the channel actor cannot be read.

Source

pub fn evolve_schema_add_field( &self, name: impl Into<String>, field_schema: Value, default: Value, ) -> Result<SchemaId, SchemaValidationError>

Evolves the channel schema by adding a defaulted field without disconnecting subscribers.

§Errors

Returns SchemaValidationError when the schema cannot be evolved.

Source

pub fn subscribe(&self) -> Result<SubscriptionHandle, LiminalError>

Subscribes to the channel, receiving every published message.

§Errors

Returns a LiminalError when a subscription cannot be created.

Source

pub fn subscribe_filtered<F>( &self, predicate: F, ) -> Result<SubscriptionHandle, LiminalError>
where F: Fn(&Envelope) -> bool + Send + Sync + 'static,

Subscribes with a delivery predicate: only messages for which predicate returns true are delivered to this subscriber. The predicate is owned and evaluated by the actor process (R3).

§Clustering

The predicate filters local-node publishes only. Under clustering (SRV-005), messages published on a remote node are delivered to this subscriber ungated — the predicate is a non-serializable closure and is not propagated across the wire, so remote nodes cannot evaluate it. If you need filtering to hold for cross-node traffic, filter again on receipt rather than relying on this predicate alone.

§Errors

Returns a LiminalError when a subscription cannot be created.

Source

pub fn unsubscribe( &self, subscription: &SubscriptionHandle, ) -> Result<(), LiminalError>

Unsubscribes the subscriber owning subscription by its process pid.

§Errors

Returns a LiminalError when the unsubscribe command fails.

Source

pub fn flush(&self) -> Result<(), LiminalError>

Flushes buffered durable channel state to the backing store before shutdown.

§Errors

Returns a LiminalError when the channel actor cannot be inspected or when the durable store flush fails.

Source

pub fn subscriber_count(&self) -> Result<usize, LiminalError>

Returns the number of currently-active subscribers on the channel actor.

§Errors

Returns a LiminalError when the actor cannot service the query.

Source

pub fn close(&self) -> Result<(), LiminalError>

Closes the channel gracefully, stopping the actor process.

§Errors

Returns a LiminalError when the channel cannot be shut down.

Trait Implementations§

Source§

impl Clone for ChannelHandle

Source§

fn clone(&self) -> ChannelHandle

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
Source§

impl Debug for ChannelHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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