You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately the current design of the inmemory channels doesn't allow to send from multiple sources, at least asfaict. I tried implementing a custom transport using flume channels, but failed to actually make them work, there seems to be sth strange happening once they are cloned.
Do you have any thoughts on what could be the issue or if this could be easily added to the existing implementation?
Current implementation
/// Returns two channel peers with buffer equal to `capacity`. Each [`Stream`] yields items sent/// through the other's [`Sink`].pubfnbounded<SinkItem,Item>(capacity:usize,) -> (Channel<SinkItem,Item>,Channel<Item,SinkItem>)whereItem:Send + Sync + 'static,SinkItem:Send + Sync + 'static,{let(tx1, rx2) = flume::bounded(capacity);let(tx2, rx1) = flume::bounded(capacity);(Channel{tx: tx1.into_sink(),rx: rx1.into_stream(),},Channel{tx: tx2.into_sink(),rx: rx2.into_stream(),},)}/// A bi-directional channel backed by a [`Sender`](flume::Sender) and [`Receiver`](flume::Receiver).pubstructChannel<Item,SinkItem>whereItem:Send + Sync + 'static,SinkItem:Send + Sync + 'static,{rx: flume::r#async::RecvStream<'static,Item>,tx: flume::r#async::SendSink<'static,SinkItem>,}impl<Item,SinkItem>CloneforChannel<Item,SinkItem>whereItem:Send + Sync + 'static,SinkItem:Send + Sync + 'static,{fnclone(&self) -> Self{Self{rx:self.rx.clone(),tx:self.tx.clone(),}}}impl<Item,SinkItem>StreamforChannel<Item,SinkItem>whereItem:Send + Sync + 'static,SinkItem:Send + Sync + 'static,{typeItem = Result<Item,ChannelError>;fnpoll_next(mutself:Pin<&mutSelf>,cx:&mutContext<'_>,) -> Poll<Option<Result<Item,ChannelError>>>{Pin::new(&mutself.rx).poll_next(cx).map(|option| option.map(Ok))}}/// Errors that occur in the sending or receiving of messages over a channel.#[derive(thiserror::Error,Debug)]pubenumChannelError{/// An error occurred sending over the channel.#[error("an error occurred sending over the channel")]Send(#[source]Box<dyn std::error::Error + Send + Sync + 'static>),}impl<Item,SinkItem>Sink<SinkItem>forChannel<Item,SinkItem>whereItem:Send + Sync + 'static,SinkItem:Send + Sync + 'static,{typeError = ChannelError;fnpoll_ready(mutself:Pin<&mutSelf>,cx:&mutContext<'_>) -> Poll<Result<(),Self::Error>>{Pin::new(&mutself.tx).poll_ready(cx).map_err(|e| ChannelError::Send(Box::new(e)))}fnstart_send(mutself:Pin<&mutSelf>,item:SinkItem) -> Result<(),Self::Error>{Pin::new(&mutself.tx).start_send(item).map_err(|e| ChannelError::Send(Box::new(e)))}fnpoll_flush(mutself:Pin<&mutSelf>,cx:&mutContext<'_>) -> Poll<Result<(),Self::Error>>{Pin::new(&mutself.tx).poll_flush(cx).map_err(|e| ChannelError::Send(Box::new(e)))}fnpoll_close(mutself:Pin<&mutSelf>,cx:&mutContext<'_>) -> Poll<Result<(),Self::Error>>{Pin::new(&mutself.tx).poll_close(cx).map_err(|e| ChannelError::Send(Box::new(e)))}}
The text was updated successfully, but these errors were encountered:
Unfortunately the current design of the inmemory channels doesn't allow to send from multiple sources, at least asfaict. I tried implementing a custom transport using
flume
channels, but failed to actually make them work, there seems to be sth strange happening once they are cloned.Do you have any thoughts on what could be the issue or if this could be easily added to the existing implementation?
Current implementation
The text was updated successfully, but these errors were encountered: