mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-25 16:31:18 +00:00
Give names to channels (#5626)
* Give names to channels * Fix * A couple more changes * More minor tweaks * Fix test
This commit is contained in:
@@ -575,9 +575,13 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
|
||||
/// If this method is called multiple times, the events are duplicated.
|
||||
///
|
||||
/// The stream never ends (unless the `NetworkWorker` gets shut down).
|
||||
pub fn event_stream(&self) -> impl Stream<Item = Event> {
|
||||
///
|
||||
/// The name passed is used to identify the channel in the Prometheus metrics. Note that the
|
||||
/// parameter is a `&'static str`, and not a `String`, in order to avoid accidentally having
|
||||
/// an unbounded set of Prometheus metrics, which would be quite bad in terms of memory
|
||||
pub fn event_stream(&self, name: &'static str) -> impl Stream<Item = Event> {
|
||||
// Note: when transitioning to stable futures, remove the `Error` entirely
|
||||
let (tx, rx) = out_events::channel();
|
||||
let (tx, rx) = out_events::channel(name);
|
||||
let _ = self.to_worker.unbounded_send(ServiceToWorkerMsg::EventStream(tx));
|
||||
rx
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user