Flume fix part 2: avoid using flume in a couple of cases, and revert attempted fix#1 (#396)

* A second attempt to avoid the flume memory leak, since the first didn't actually work

* No luck with second flume fix, so revert to futures::mpsc in a few places)

* cargo fmt

* Add a comment to cover use of into_stream
This commit is contained in:
James Wilson
2021-09-03 15:55:25 +01:00
committed by GitHub
parent 2932075783
commit a3ffaf3c44
7 changed files with 29 additions and 43 deletions
+4 -4
View File
@@ -21,7 +21,7 @@ use std::{
use crate::feed_message_de::FeedMessage;
use common::ws_client;
use futures::{Stream, StreamExt};
use futures::{channel, Stream, StreamExt};
/// Wrap a `ws_client::Sender` with convenient utility methods for shard connections
pub struct ShardSender(ws_client::Sender);
@@ -37,7 +37,7 @@ impl ShardSender {
pub fn send_json_binary(
&mut self,
json: serde_json::Value,
) -> Result<(), flume::SendError<ws_client::SentMessage>> {
) -> Result<(), channel::mpsc::SendError> {
let bytes = serde_json::to_vec(&json).expect("valid bytes");
self.unbounded_send(ws_client::SentMessage::Binary(bytes))
}
@@ -45,7 +45,7 @@ impl ShardSender {
pub fn send_json_text(
&mut self,
json: serde_json::Value,
) -> Result<(), flume::SendError<ws_client::SentMessage>> {
) -> Result<(), channel::mpsc::SendError> {
let s = serde_json::to_string(&json).expect("valid string");
self.unbounded_send(ws_client::SentMessage::Text(s))
}
@@ -123,7 +123,7 @@ impl FeedSender {
&self,
command: S,
param: S,
) -> Result<(), flume::SendError<ws_client::SentMessage>> {
) -> Result<(), channel::mpsc::SendError> {
self.unbounded_send(ws_client::SentMessage::Text(format!(
"{}:{}",
command.as_ref(),