Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Millione committed Oct 15, 2024
1 parent 9370f24 commit 0883099
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
6 changes: 0 additions & 6 deletions volo-thrift/src/transport/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,3 @@ impl Stream for Incoming {
}
}
}

#[cfg(test)]
mod tests {
#[test]
fn test() {}
}
2 changes: 1 addition & 1 deletion volo-thrift/src/transport/multiplex/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ where
}
}
if cx.transport.should_reuse && resp.is_ok() {
if let Transport::Pooled(pooled) = transport {
if let Transport::TcpOrUnix(pooled) = transport {
pooled.reuse().await;
}
}
Expand Down
2 changes: 1 addition & 1 deletion volo-thrift/src/transport/pingpong/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ where
.call((target, shmipc_target.clone(), Ver::PingPong))
.await?;
cx.stats.record_make_transport_end_at();
if let Transport::UnPooled(_) = transport {
if let Transport::Shm(_) = transport {
cx.rpc_info
.caller_mut()
.set_transport(volo::net::shm::Transport(FastStr::new("shmipc")))
Expand Down
2 changes: 1 addition & 1 deletion volo-thrift/src/transport/pingpong/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub async fn serve<Svc, Req, Resp, E, D, SP>(
cx.rpc_info.caller_mut().set_address(peer_addr.clone());
} else {
cx.rpc_info
.caller_mut()
.callee_mut()
.set_transport(volo::net::shm::Transport(FastStr::new("shmipc")));
cx.rpc_info
.caller_mut()
Expand Down
2 changes: 1 addition & 1 deletion volo-thrift/src/transport/pool/make_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
let mt = self.inner.clone();
if let Some(addr) = kv.1 {
if let Ok(resp) = mt.call(addr.clone()).await {
return Ok(Transport::UnPooled(resp));
return Ok(Transport::Shm(resp));
}
}
self.pool
Expand Down
20 changes: 10 additions & 10 deletions volo-thrift/src/transport/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,17 +416,17 @@ struct Idle<T> {
}

pub enum Transport<K: Key, T: Poolable> {
Pooled(Pooled<K, T>),
UnPooled(T),
TcpOrUnix(Pooled<K, T>),
Shm(T),
}

impl<E: Encoder, D: Decoder> Transport<Address, ThriftTransport<E, D>> {
pub async fn reuse(self) {
match self {
Transport::Pooled(pooled) => {
Transport::TcpOrUnix(pooled) => {
pooled.reuse().await;
}
Transport::UnPooled(t) => {
Transport::Shm(t) => {
t.reuse().await;
}
}
Expand All @@ -435,30 +435,30 @@ impl<E: Encoder, D: Decoder> Transport<Address, ThriftTransport<E, D>> {

impl<K: Key, T: Poolable> From<Pooled<K, T>> for Transport<K, T> {
fn from(pooled: Pooled<K, T>) -> Self {
Transport::Pooled(pooled)
Transport::TcpOrUnix(pooled)
}
}

impl<K: Key, T: Poolable> From<T> for Transport<K, T> {
fn from(t: T) -> Self {
Transport::UnPooled(t)
Transport::Shm(t)
}
}

impl<K: Key, T: Poolable> AsRef<T> for Transport<K, T> {
fn as_ref(&self) -> &T {
match self {
Transport::Pooled(pooled) => pooled.t.as_ref().expect("not dropped"),
Transport::UnPooled(t) => t,
Transport::TcpOrUnix(pooled) => pooled.t.as_ref().expect("not dropped"),
Transport::Shm(t) => t,
}
}
}

impl<K: Key, T: Poolable> AsMut<T> for Transport<K, T> {
fn as_mut(&mut self) -> &mut T {
match self {
Transport::Pooled(pooled) => pooled.t.as_mut().expect("not dropped"),
Transport::UnPooled(t) => t,
Transport::TcpOrUnix(pooled) => pooled.t.as_mut().expect("not dropped"),
Transport::Shm(t) => t,
}
}
}
Expand Down

0 comments on commit 0883099

Please sign in to comment.