Remove direct dependencies on tokio, bytes, reduce lock contention for circuitbreaker

This commit is contained in:
asonix
2020-12-29 11:27:14 -06:00
parent 9923d4d107
commit d7e68190c4
9 changed files with 82 additions and 58 deletions
+4 -3
View File
@@ -1,16 +1,17 @@
use actix_web::{
dev::{Payload, Service, ServiceRequest, Transform},
http::StatusCode,
web::BytesMut,
HttpMessage, HttpResponse, ResponseError,
};
use bytes::BytesMut;
use futures::{
channel::mpsc::channel,
future::{ok, try_join, LocalBoxFuture, Ready},
sink::SinkExt,
stream::StreamExt,
};
use log::{error, info};
use std::task::{Context, Poll};
use tokio::sync::mpsc::channel;
#[derive(Clone, Debug)]
pub struct DebugPayload(pub bool);
@@ -68,7 +69,7 @@ where
fn call(&mut self, mut req: S::Request) -> Self::Future {
if self.0 {
let (mut tx, rx) = channel(1);
let (mut tx, rx) = channel(0);
let mut pl = req.take_payload();
req.set_payload(Payload::Stream(Box::pin(rx)));