pub(crate) fn build<S>(
    config: Arc<WebsocketConfig>,
    remote_addr: Url2,
    mut sink: S,
) -> ToSocketSinkSender
where
    S: 'static + std::marker::Unpin + futures::sink::Sink<tungstenite::Message> + Send,
    <S as futures::sink::Sink<tungstenite::Message>>::Error: std::fmt::Debug,
{
    let (send_sink, mut recv_sink) =
        tokio::sync::mpsc::channel::<ToSocketSink>(config.max_send_queue);
    tokio::task::spawn(async move {
        tracing::trace!(
            message = "starting socket sink task",
            %remote_addr,
        );
        use tokio::stream::StreamExt;
        while let Some((msg, send_complete)) = recv_sink.next().await {
            use futures::sink::SinkExt;
            if let Err(e) = sink.send(msg).await {
                tracing::error!(error = ?e);
                // end task
                break;
            }
            let _ = send_complete.send(());
        }
        tracing::info!(
            message = "socket sink task ended",
            %remote_addr,
        );
    });
    send_sink
}
/// See module-level documentation for this internal task
See module-level documentation for this internal task
See module - level documentation for this internal task
pub(crate) fn build<S>(
    config: Arc<WebsocketConfig>,
    remote_addr: Url2,
    mut sink: S,
) -> ToSocketSinkSender
where
    S: 'static + std::marker::Unpin + futures::sink::Sink<tungstenite::Message> + Send,
    <S as futures::sink::Sink<tungstenite::Message>>::Error: std::fmt::Debug,
{
    let (send_sink, mut recv_sink) =
        tokio::sync::mpsc::channel::<ToSocketSink>(config.max_send_queue);
    tokio::task::spawn(async move {
        tracing::trace!(
            message = "starting socket sink task",
            %remote_addr,
        );
        use tokio::stream::StreamExt;
        while let Some((msg, send_complete)) = recv_sink.next().await {
            use futures::sink::SinkExt;
            if let Err(e) = sink.send(msg).await {
                tracing::error!(error = ?e);
                // end task
                break;
            }
            let _ = send_complete.send(());
        }
        tracing::info!(
            message = "socket sink task ended",
            %remote_addr,
        );
    });
    send_sink
}
pub ( crate ) fn build < S > ( config : Arc < WebsocketConfig > , remote_addr : Url2 , mut sink : S , ) -> ToSocketSinkSender where S : ' static + std :: marker :: Unpin + futures :: sink :: Sink < tungstenite :: Message > + Send , < S as futures :: sink :: Sink < tungstenite :: Message > > :: Error : std :: fmt :: Debug , { let ( send_sink , mut recv_sink ) = tokio :: sync :: mpsc :: channel :: < ToSocketSink > ( config . max_send_queue ) ; tokio :: task :: spawn ( async move { tracing :: trace ! ( message " " remote_addr ) ; use tokio :: stream :: StreamExt ; while let Some ( ( msg , send_complete ) ) = recv_sink . next ( ) . await { use futures :: sink :: SinkExt ; if let Err ( e ) = sink . send ( msg ) . await { tracing :: error ! ( error e ) ; // end task break ; } let _ = send_complete . send ( ( ) ) ; } tracing :: info ! ( message " " remote_addr ) ; } ) ; send_sink }
See module-level documentation for this internal task
See module - level documentation for this internal task
config
Arc<WebsocketConfig>
remote_addr
Url2
sink
S
config
Arc<WebsocketConfig>
remote_addr
Url2
sink
S