pub trait Engine:
'static
+ Send
+ Sync
+ Debug
+ MessageEncryptorApi
+ MessageDecryptorApi {
type ClientState: 'static + Send + Sync;
type TaskHandle: 'static + Send;
type Interval: 'static + Send;
// Required methods
fn spawn<F>(fut: F) -> Self::TaskHandle
where F: Future<Output = ()> + Send + 'static;
fn abort_task(handle: &mut Self::TaskHandle);
fn new_interval(period: Duration) -> Self::Interval;
fn interval_tick<'a>(
interval: &'a mut Self::Interval,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
fn random_subscription_suffix() -> String
where Self: Sized;
// Provided method
fn name() -> &'static str
where Self: Sized { ... }
}Expand description
Marker trait labelling a runtime engine. Implementations select the
concrete storage type (Self::ClientState) that backs the engine’s
branch of crate::PulsarClient<E>.
'static + Send + Sync mirrors what we already require of producers and
consumers; downstream users that hand PulsarClient<E> to a tokio
spawn (or moonpool spawn) need at least that.
§Task and timer primitives (ADR-0025 phase 1)
The associated Self::TaskHandle and Self::Interval types plus the
Self::spawn / Self::abort_task / Self::new_interval /
Self::interval_tick methods give the façade an engine-agnostic way to
spawn background tasks and drive periodic timers. They are the
prerequisite for moving PartitionedProducer::health_loop,
TableView::drain_task, MultiTopicsConsumer::auto_update, and the
other surface lifts off impl PulsarClient<TokioEngine>. See
ADR-0025.
Required Associated Types§
Sourcetype ClientState: 'static + Send + Sync
type ClientState: 'static + Send + Sync
Per-engine state stored inside crate::PulsarClient<E>. The tokio
engine plugs in magnetar_runtime_tokio::Client; the moonpool
engine plugs in (Arc<moonpool::ConnectionShared>, moonpool::DriverHandle). Both bundles are 'static + Send + Sync
so the façade can be moved across spawn boundaries unchanged.
Sourcetype TaskHandle: 'static + Send
type TaskHandle: 'static + Send
Opaque, cancel-safe handle to a background task spawned via
Self::spawn. Dropping the handle aborts the task on the tokio
engine; explicit Self::abort_task is the happens-before-Drop
path the façade uses on shutdown.
Sourcetype Interval: 'static + Send
type Interval: 'static + Send
Opaque periodic timer created via Self::new_interval. The
façade drives ticks via Self::interval_tick.
Required Methods§
Sourcefn spawn<F>(fut: F) -> Self::TaskHandle
fn spawn<F>(fut: F) -> Self::TaskHandle
Spawn an async future on the engine’s executor. Returns a cancel-
safe Self::TaskHandle. Tokio wraps ::tokio::spawn; moonpool
delegates through its Providers::TaskProvider (moonpool_core).
Sourcefn abort_task(handle: &mut Self::TaskHandle)
fn abort_task(handle: &mut Self::TaskHandle)
Abort a spawned task. Idempotent: calling on an already-completed or already-aborted handle is a no-op.
Sourcefn new_interval(period: Duration) -> Self::Interval
fn new_interval(period: Duration) -> Self::Interval
Create a periodic timer with period between ticks. The first
tick fires immediately (matches tokio::time::interval).
Sourcefn interval_tick<'a>(
interval: &'a mut Self::Interval,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
fn interval_tick<'a>( interval: &'a mut Self::Interval, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
Await the next tick. The returned future is Send and boxed so
the caller can .await from a generic context without exposing
the engine-specific timer shape.
Sourcefn random_subscription_suffix() -> Stringwhere
Self: Sized,
fn random_subscription_suffix() -> Stringwhere
Self: Sized,
Engine-injected id provider for the façade’s auto-generated
subscription names (Reader, TableView) and for the opt-in
ProducerBuilder::unique_name_suffix
policy (issue #406). Tokio plugs in
Uuid::new_v4().simple() (RFC 4122 random); moonpool plugs in
a process-global atomic counter so deterministic-simulation runs
produce stable, reproducible names. Callers that need fully
deterministic names across processes should always pass an
explicit subscription / reader / producer name through the builder and
leave the suffix policy off.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".