mirror of
https://github.com/OMGeeky/tarpc.git
synced 2025-12-29 15:49:52 +01:00
Add future::Connect::connect_remotely.
This commit is contained in:
@@ -92,7 +92,12 @@ pub mod future {
|
||||
|
||||
/// Connects to a server located at the given address, using a remote to the default
|
||||
/// reactor.
|
||||
fn connect(addr: &SocketAddr) -> Self::ConnectFut;
|
||||
fn connect(addr: &SocketAddr) -> Self::ConnectFut {
|
||||
Self::connect_remotely(addr, &REMOTE)
|
||||
}
|
||||
|
||||
/// Connects to a server located at the given address, using the given reactor remote.
|
||||
fn connect_remotely(addr: &SocketAddr, remote: &reactor::Remote) -> Self::ConnectFut;
|
||||
|
||||
/// Connects to a server located at the given address, using the given reactor handle.
|
||||
fn connect_with(addr: &SocketAddr, handle: &'a reactor::Handle) -> Self::ConnectWithFut;
|
||||
@@ -167,12 +172,10 @@ pub mod future {
|
||||
type ConnectFut = ConnectFuture<Req, Resp, E>;
|
||||
type ConnectWithFut = ConnectWithFuture<'a, Req, Resp, E>;
|
||||
|
||||
/// Starts an event loop on a thread and registers a new client
|
||||
/// connected to the given address.
|
||||
fn connect(addr: &SocketAddr) -> Self::ConnectFut {
|
||||
fn connect_remotely(addr: &SocketAddr, remote: &reactor::Remote) -> Self::ConnectFut {
|
||||
let addr = *addr;
|
||||
let (tx, rx) = futures::oneshot();
|
||||
REMOTE.spawn(move |handle| {
|
||||
remote.spawn(move |handle| {
|
||||
let handle2 = handle.clone();
|
||||
TcpStream::connect(&addr, handle)
|
||||
.map(move |tcp| Client::new(tcp, &handle2))
|
||||
|
||||
@@ -685,9 +685,12 @@ macro_rules! service {
|
||||
type ConnectFut = __tarpc_service_ConnectFuture<Self>;
|
||||
type ConnectWithFut = __tarpc_service_ConnectWithFuture<'a, Self>;
|
||||
|
||||
fn connect(__tarpc_service_addr: &::std::net::SocketAddr) -> Self::ConnectFut {
|
||||
let client = <__tarpc_service_Client as $crate::future::Connect>::connect(
|
||||
__tarpc_service_addr);
|
||||
fn connect_remotely(__tarpc_service_addr: &::std::net::SocketAddr,
|
||||
__tarpc_service_remote: &$crate::tokio_core::reactor::Remote)
|
||||
-> Self::ConnectFut
|
||||
{
|
||||
let client = <__tarpc_service_Client as $crate::future::Connect>::connect_remotely(
|
||||
__tarpc_service_addr, __tarpc_service_remote);
|
||||
|
||||
__tarpc_service_ConnectFuture {
|
||||
inner: $crate::futures::Future::map(client, FutureClient)
|
||||
|
||||
Reference in New Issue
Block a user