Trait grafana_plugin_sdk::pluginv2::stream_server::Stream
source · pub trait Stream: Send + Sync + 'static {
type RunStreamStream: Stream<Item = Result<StreamPacket, Status>> + Send + 'static;
// Required methods
fn subscribe_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<SubscribeStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<SubscribeStreamResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn run_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<RunStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::RunStreamStream>, Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn publish_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<PublishStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<PublishStreamResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Generated trait containing gRPC methods that should be implemented for use with StreamServer.
Required Associated Types§
sourcetype RunStreamStream: Stream<Item = Result<StreamPacket, Status>> + Send + 'static
type RunStreamStream: Stream<Item = Result<StreamPacket, Status>> + Send + 'static
Server streaming response type for the RunStream method.
Required Methods§
sourcefn subscribe_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<SubscribeStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<SubscribeStreamResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<SubscribeStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<SubscribeStreamResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
SubscribeStream called when a user tries to subscribe to a plugin/datasource managed channel path – thus plugin can check subscribe permissions and communicate options with Grafana Core. When the first subscriber joins a channel, RunStream will be called.
sourcefn run_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<RunStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::RunStreamStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<RunStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::RunStreamStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
RunStream will be initiated by Grafana to consume a stream. RunStream will be called once for the first client successfully subscribed to a channel path. When Grafana detects that there are no longer any subscribers inside a channel, the call will be terminated until next active subscriber appears. Call termination can happen with a delay.
sourcefn publish_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<PublishStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<PublishStreamResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn publish_stream<'life0, 'async_trait>(
&'life0 self,
request: Request<PublishStreamRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<PublishStreamResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
PublishStream called when a user tries to publish to a plugin/datasource managed channel path. Here plugin can check publish permissions and modify publication data if required.