mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-02-23 15:49:54 +01:00
Add a reactor::Core field to SyncClient.
This allows the client to drive its own execution, as one would expect.
Previously, the reactor had to be driven on a separate thread, which was confusing.
This has a couple notable side effects:
1. SyncClient is no longer `Clone`. This is because `reactor::Core`
is not `Clone`, and creating one is not infallible
(`Core::new` returns a `Result`).
2. SyncClient does not use the user-specified `client::Options::handle` or
`client::Options::remote`, because it constructs its own reactor.
This commit is contained in:
@@ -122,7 +122,7 @@ fn main() {
|
||||
.wait()
|
||||
.unwrap();
|
||||
|
||||
let publisher_client =
|
||||
let mut publisher_client =
|
||||
publisher::SyncClient::connect(publisher_addr, client::Options::default()).unwrap();
|
||||
|
||||
let subscriber1 = Subscriber::listen(0);
|
||||
|
||||
@@ -51,7 +51,7 @@ impl SyncService for HelloServer {
|
||||
|
||||
fn main() {
|
||||
let addr = HelloServer.listen("localhost:10000", server::Options::default()).unwrap();
|
||||
let client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
let mut client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
println!("{}", client.hello("Mom".to_string()).unwrap());
|
||||
println!("{}", client.hello("".to_string()).unwrap_err());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ impl SyncService for HelloServer {
|
||||
fn main() {
|
||||
let addr = "localhost:10000";
|
||||
HelloServer.listen(addr, server::Options::default()).unwrap();
|
||||
let client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
let mut client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
println!("{}", client.hello("Mom".to_string()).unwrap());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ fn main() {
|
||||
.wait()
|
||||
.unwrap();
|
||||
|
||||
let double_client = double::SyncClient::connect(double_addr, client::Options::default())
|
||||
let mut double_client = double::SyncClient::connect(double_addr, client::Options::default())
|
||||
.unwrap();
|
||||
for i in 0..5 {
|
||||
println!("{:?}", double_client.double(i).unwrap());
|
||||
|
||||
@@ -57,7 +57,7 @@ fn bench_tarpc(target: u64) {
|
||||
server::Options::default())
|
||||
.wait()
|
||||
.unwrap();
|
||||
let client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
let mut client = SyncClient::connect(addr, client::Options::default()).unwrap();
|
||||
let start = time::Instant::now();
|
||||
let mut nread = 0;
|
||||
while nread < target {
|
||||
|
||||
@@ -68,8 +68,8 @@ fn main() {
|
||||
.wait()
|
||||
.unwrap();
|
||||
|
||||
let bar_client = bar::SyncClient::connect(bar_addr, client::Options::default()).unwrap();
|
||||
let baz_client = baz::SyncClient::connect(baz_addr, client::Options::default()).unwrap();
|
||||
let mut bar_client = bar::SyncClient::connect(bar_addr, client::Options::default()).unwrap();
|
||||
let mut baz_client = baz::SyncClient::connect(baz_addr, client::Options::default()).unwrap();
|
||||
|
||||
info!("Result: {:?}", bar_client.bar(17));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user