Struct grafana_plugin_sdk::live::Channel
source · pub struct Channel { /* private fields */ }
Expand description
The identifier of a pub/sub channel in Grafana Live.
Channels are represented as /
delimited strings containing their three components,
and can be parsed from such strings using str::parse
.
When included in the Metadata
of a Frame
,
channels are (de)serialized from this format.
// Note that the 'path' can contain '/'s.
let channel: Channel = "plugin/my-cool-plugin/streams/custom-streaming-feature"
.parse()
.expect("valid channel");
assert_eq!(channel.scope(), Scope::Plugin);
assert_eq!(channel.namespace().as_str(), "my-cool-plugin");
assert_eq!(channel.path().as_str(), "streams/custom-streaming-feature");
assert_eq!(
channel.to_string(),
String::from("plugin/my-cool-plugin/streams/custom-streaming-feature"),
);
See the channel guide for more information.
Implementations§
source§impl Channel
impl Channel
sourcepub fn new(scope: Scope, namespace: Namespace, path: Path) -> Self
pub fn new(scope: Scope, namespace: Namespace, path: Path) -> Self
Create a new channel from pre-validated parts.
sourcepub fn scope(&self) -> Scope
pub fn scope(&self) -> Scope
Get the scope of this channel.
The scope determines the purpose of the channel; for example, channels used
internally by Grafana have scope Grafana
, while channels
used by datasource plugins have scope Datasource
.
sourcepub fn namespace(&self) -> &Namespace
pub fn namespace(&self) -> &Namespace
Get the namespace of this channel.
The namespace has a different meaning depending on scope:
- when scope is
Scope::Grafana
, namespace is a “feature” - when scope is
Scope::Plugin
, namespace is the plugin name - when scope is
Scope::Datasource
, namespace is the datasourceuid
. - when scope is
Scope::Stream
, namespace is the stream ID.
For example, scope Grafana
could have a namespace called dashboard
,
and all messages on such a channel would related to real-time dashboard events.
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Get the path of this channel.
The path usually contains the identifier of some concrete resource within a namespace, such as the ID of a dashboard that a user is currently looking at.
This can be anything the plugin author desires, provided it only includes the characters
defined in the Path
documentation.
Trait Implementations§
source§impl PartialEq for Channel
impl PartialEq for Channel
impl Eq for Channel
impl StructuralEq for Channel
impl StructuralPartialEq for Channel
Auto Trait Implementations§
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnwindSafe for Channel
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request