Skip to main content

GraphqlSubscriptionSource

Trait GraphqlSubscriptionSource 

Source
pub trait GraphqlSubscriptionSource: Send + Sync {
    // Required method
    fn subscribe_stream<'a>(
        &'a self,
        subject: &'a Subject,
    ) -> Pin<Box<dyn Future<Output = Result<JsonValueStream, Error>> + Send + 'a>>;
}
Expand description

A source of live event streams keyed by subject. Implementations are typically backed by themql-sse’s TokioSsePublisher (broadcast channel) but any transport that can produce a stream of JSON values for a given subject can implement this trait.

This trait is dyn-compatible so SubscriptionRoot can hold Arc<dyn GraphqlSubscriptionSource>.

Required Methods§

Source

fn subscribe_stream<'a>( &'a self, subject: &'a Subject, ) -> Pin<Box<dyn Future<Output = Result<JsonValueStream, Error>> + Send + 'a>>

Subscribe to subject and return a stream of JSON values, one per published event.

§Errors

Returns [Error] if the subscription cannot be established.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl GraphqlSubscriptionSource for TokioSsePublisher

Source§

fn subscribe_stream<'a>( &'a self, subject: &'a Subject, ) -> Pin<Box<dyn Future<Output = Result<JsonValueStream, Error>> + Send + 'a>>

Implementors§