Rename PeerServer -> peer::Server
This commit is contained in:
parent
77191e62f6
commit
d1b3e8fe6b
|
|
@ -15,4 +15,4 @@ pub use client::Client;
|
||||||
pub use connector::PeerConnector;
|
pub use connector::PeerConnector;
|
||||||
pub use error::{HandshakeError, PeerError, SharedPeerError};
|
pub use error::{HandshakeError, PeerError, SharedPeerError};
|
||||||
pub use handshake::PeerHandshake;
|
pub use handshake::PeerHandshake;
|
||||||
pub use server::PeerServer;
|
pub use server::Server;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct Client {
|
||||||
pub(super) error_slot: ErrorSlot,
|
pub(super) error_slot: ErrorSlot,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A message from the `peer::Client` to the `PeerServer`, containing both a
|
/// A message from the `peer::Client` to the `peer::Server`, containing both a
|
||||||
/// request and a return message channel. The reason the return channel is
|
/// request and a return message channel. The reason the return channel is
|
||||||
/// included is because `peer::Client::call` returns a future that may be moved
|
/// included is because `peer::Client::call` returns a future that may be moved
|
||||||
/// around before it resolves, so the future must have ownership of the channel
|
/// around before it resolves, so the future must have ownership of the channel
|
||||||
|
|
@ -43,7 +43,7 @@ impl Service<Request> for Client {
|
||||||
Poll::Ready(Err(self
|
Poll::Ready(Err(self
|
||||||
.error_slot
|
.error_slot
|
||||||
.try_get_error()
|
.try_get_error()
|
||||||
.expect("failed PeerServers must set their error slot")))
|
.expect("failed servers must set their error slot")))
|
||||||
} else {
|
} else {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ impl Service<Request> for Client {
|
||||||
future::ready(Err(self
|
future::ready(Err(self
|
||||||
.error_slot
|
.error_slot
|
||||||
.try_get_error()
|
.try_get_error()
|
||||||
.expect("failed PeerServers must set their error slot")))
|
.expect("failed servers must set their error slot")))
|
||||||
.instrument(self.span.clone())
|
.instrument(self.span.clone())
|
||||||
.boxed()
|
.boxed()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ pub enum PeerError {
|
||||||
/// The remote peer closed the connection.
|
/// The remote peer closed the connection.
|
||||||
#[error("Peer closed connection")]
|
#[error("Peer closed connection")]
|
||||||
ConnectionClosed,
|
ConnectionClosed,
|
||||||
/// The [`peer::Client`] half of the [`peer::Client`]/[`PeerServer`] pair died before
|
/// The [`peer::Client`] half of the [`peer::Client`]/[`peer::Server`] pair died before
|
||||||
/// the [`Server`] half did.
|
/// the [`Server`] half did.
|
||||||
#[error("peer::Client instance died")]
|
#[error("peer::Client instance died")]
|
||||||
DeadClient,
|
DeadClient,
|
||||||
/// The [`PeerServer`] half of the [`PeerServer`]/[`peer::Client`] pair died before
|
/// The [`peer::Server`] half of the [`peer::Server`]/[`peer::Client`] pair died before
|
||||||
/// the [`peer::Client`] half did.
|
/// the [`peer::Client`] half did.
|
||||||
#[error("PeerServer instance died")]
|
#[error("peer::Server instance died")]
|
||||||
DeadPeerServer,
|
DeadServer,
|
||||||
/// The remote peer did not respond to a [`peer::Client`] request in time.
|
/// The remote peer did not respond to a [`peer::Client`] request in time.
|
||||||
#[error("Client request timed out")]
|
#[error("Client request timed out")]
|
||||||
ClientRequestTimeout,
|
ClientRequestTimeout,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use crate::{
|
||||||
BoxedStdError, Config,
|
BoxedStdError, Config,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{error::ErrorSlot, server::ServerState, HandshakeError, Client, PeerServer};
|
use super::{error::ErrorSlot, server::ServerState, HandshakeError, Client, Server};
|
||||||
|
|
||||||
/// A [`Service`] that handshakes with a remote peer and constructs a
|
/// A [`Service`] that handshakes with a remote peer and constructs a
|
||||||
/// client/server pair.
|
/// client/server pair.
|
||||||
|
|
@ -192,7 +192,7 @@ where
|
||||||
|
|
||||||
let (peer_tx, peer_rx) = stream.split();
|
let (peer_tx, peer_rx) = stream.split();
|
||||||
|
|
||||||
let server = PeerServer {
|
let server = Server {
|
||||||
state: ServerState::AwaitingRequest,
|
state: ServerState::AwaitingRequest,
|
||||||
svc: internal_service,
|
svc: internal_service,
|
||||||
client_rx: server_rx,
|
client_rx: server_rx,
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ pub(super) enum ServerState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The "server" duplex half of a peer connection.
|
/// The "server" duplex half of a peer connection.
|
||||||
pub struct PeerServer<S, Tx> {
|
pub struct Server<S, Tx> {
|
||||||
pub(super) state: ServerState,
|
pub(super) state: ServerState,
|
||||||
/// A timeout for a client request. This is stored separately from
|
/// A timeout for a client request. This is stored separately from
|
||||||
/// ServerState so that we can move the future out of it independently of
|
/// ServerState so that we can move the future out of it independently of
|
||||||
|
|
@ -48,7 +48,7 @@ pub struct PeerServer<S, Tx> {
|
||||||
pub(super) peer_tx: Tx,
|
pub(super) peer_tx: Tx,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, Tx> PeerServer<S, Tx>
|
impl<S, Tx> Server<S, Tx>
|
||||||
where
|
where
|
||||||
S: Service<Request, Response = Response, Error = BoxedStdError>,
|
S: Service<Request, Response = Response, Error = BoxedStdError>,
|
||||||
S::Error: Into<BoxedStdError>,
|
S::Error: Into<BoxedStdError>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue