pub struct InMemoryTopicEventBus { /* private fields */ }Expand description
内存 Topic 总线:同进程多订阅者;不跨进程、不持久化
Implementations§
Source§impl InMemoryTopicEventBus
impl InMemoryTopicEventBus
pub fn new(capacity: usize) -> Arc<InMemoryTopicEventBus> ⓘ
Sourcepub fn new_default() -> Arc<InMemoryTopicEventBus> ⓘ
pub fn new_default() -> Arc<InMemoryTopicEventBus> ⓘ
Sourcepub fn receiver_count(&self) -> usize
pub fn receiver_count(&self) -> usize
当前活跃订阅者数(调试用容量规划)
Sourcepub fn subscribe(&self) -> Receiver<TopicBroadcast>
pub fn subscribe(&self) -> Receiver<TopicBroadcast>
订阅所有 topic;业务侧在循环中过滤 msg.topic
Trait Implementations§
Source§impl TopicEventBus for InMemoryTopicEventBus
impl TopicEventBus for InMemoryTopicEventBus
Source§async fn publish(
&self,
ctx: &Arc<Context>,
topic: &str,
envelope: &EventEnvelope,
) -> Result<(), FlareError>
async fn publish( &self, ctx: &Arc<Context>, topic: &str, envelope: &EventEnvelope, ) -> Result<(), FlareError>
发布;分布式实现将
ctx 写入 MQ 头;内存实现扇出 super::in_memory_topic_event_bus::TopicBroadcastSource§fn publish_batch<'a>(
&'a self,
ctx: &'a Arc<Context>,
topic: &'a str,
envelopes: &'a [EventEnvelope],
) -> impl Future<Output = Result<(), FlareError>> + Send + 'a
fn publish_batch<'a>( &'a self, ctx: &'a Arc<Context>, topic: &'a str, envelopes: &'a [EventEnvelope], ) -> impl Future<Output = Result<(), FlareError>> + Send + 'a
批量发布(默认顺序调用
publish,保证同一 topic 下发送次序与调用顺序一致)Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryTopicEventBus
impl !UnwindSafe for InMemoryTopicEventBus
impl Freeze for InMemoryTopicEventBus
impl Send for InMemoryTopicEventBus
impl Sync for InMemoryTopicEventBus
impl Unpin for InMemoryTopicEventBus
impl UnsafeUnpin for InMemoryTopicEventBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request