From b1eec3131fda1c05a08f2b6e39f14f5cc3d2960b Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 12 Feb 2018 22:56:47 -0800 Subject: [PATCH] use newer api --- guide/src/qs_10.md | 2 +- guide/src/qs_3_5.md | 6 +++--- guide/src/qs_4.md | 4 ++-- src/client/connector.rs | 4 ++-- src/server/srv.rs | 16 ++++++++-------- src/server/worker.rs | 4 ++-- src/test.rs | 2 +- src/ws/client.rs | 2 +- tests/test_server.rs | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/guide/src/qs_10.md b/guide/src/qs_10.md index 1334ecdb..b3c5a8e0 100644 --- a/guide/src/qs_10.md +++ b/guide/src/qs_10.md @@ -200,7 +200,7 @@ fn main() { ))) .bind("127.0.0.1:59880").unwrap() .start(); -# actix::Arbiter::system().send(actix::msgs::SystemExit(0)); +# actix::Arbiter::system().do_send(actix::msgs::SystemExit(0)); # let _ = sys.run(); } ``` diff --git a/guide/src/qs_3_5.md b/guide/src/qs_3_5.md index ef35973d..99c2bcd9 100644 --- a/guide/src/qs_3_5.md +++ b/guide/src/qs_3_5.md @@ -24,7 +24,7 @@ fn main() { .bind("127.0.0.1:59080").unwrap() .start(); -# actix::Arbiter::system().send(actix::msgs::SystemExit(0)); +# actix::Arbiter::system().do_send(actix::msgs::SystemExit(0)); let _ = sys.run(); } ``` @@ -52,7 +52,7 @@ use std::sync::mpsc; fn main() { let (tx, rx) = mpsc::channel(); - + thread::spawn(move || { let sys = actix::System::new("http-server"); let addr = HttpServer::new( @@ -66,7 +66,7 @@ fn main() { }); let addr = rx.recv().unwrap(); - let _ = addr.call( + let _ = addr.send( server::StopServer{graceful:true}).wait(); // <- Send `StopServer` message to server. } ``` diff --git a/guide/src/qs_4.md b/guide/src/qs_4.md index a8424a4a..c7cbc6c9 100644 --- a/guide/src/qs_4.md +++ b/guide/src/qs_4.md @@ -109,7 +109,7 @@ fn main() { .start(); println!("Started http server: 127.0.0.1:8088"); -# actix::Arbiter::system().send(actix::msgs::SystemExit(0)); +# actix::Arbiter::system().do_send(actix::msgs::SystemExit(0)); let _ = sys.run(); } ``` @@ -167,7 +167,7 @@ fn main() { .start(); println!("Started http server: 127.0.0.1:8088"); -# actix::Arbiter::system().send(actix::msgs::SystemExit(0)); +# actix::Arbiter::system().do_send(actix::msgs::SystemExit(0)); let _ = sys.run(); } ``` diff --git a/src/client/connector.rs b/src/client/connector.rs index af708bbb..2d49a06d 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -146,7 +146,7 @@ impl ClientConnector { /// if let Ok(mut stream) = res { /// stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap(); /// } - /// # Arbiter::system().send(actix::msgs::SystemExit(0)); + /// # Arbiter::system().do_send(actix::msgs::SystemExit(0)); /// Ok(()) /// }) /// }); @@ -191,7 +191,7 @@ impl Handler for ClientConnector { ActorResponse::async( Connector::from_registry() - .call(ResolveConnect::host_and_port(&host, port)) + .send(ResolveConnect::host_and_port(&host, port)) .into_actor(self) .map_err(|_, _, _| ClientConnectorError::Disconnected) .and_then(move |res, _act, _| { diff --git a/src/server/srv.rs b/src/server/srv.rs index 2df54288..3b828a1c 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -264,7 +264,7 @@ impl HttpServer /// .resource("/", |r| r.h(httpcodes::HTTPOk))) /// .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0") /// .start(); - /// # actix::Arbiter::system().send(actix::msgs::SystemExit(0)); + /// # actix::Arbiter::system().do_send(actix::msgs::SystemExit(0)); /// /// let _ = sys.run(); // <- Run actix system, this method actually starts all async processes /// } @@ -289,7 +289,7 @@ impl HttpServer // start http server actor let signals = self.subscribe_to_signals(); let addr: Addr = Actor::start(self); - signals.map(|signals| signals.send( + signals.map(|signals| signals.do_send( signal::Subscribe(addr.clone().recipient()))); addr } @@ -351,7 +351,7 @@ impl HttpServer // start http server actor let signals = self.subscribe_to_signals(); let addr: Addr = Actor::start(self); - signals.map(|signals| signals.send( + signals.map(|signals| signals.do_send( signal::Subscribe(addr.clone().recipient()))); Ok(addr) } @@ -395,7 +395,7 @@ impl HttpServer // start http server actor let signals = self.subscribe_to_signals(); let addr: Addr = Actor::start(self); - signals.map(|signals| signals.send( + signals.map(|signals| signals.do_send( signal::Subscribe(addr.clone().recipient()))); Ok(addr) } @@ -442,7 +442,7 @@ impl HttpServer .map(move |(t, _)| Conn{io: WrapperStream::new(t), peer: None, http2: false})); self }); - signals.map(|signals| signals.send( + signals.map(|signals| signals.do_send( signal::Subscribe(addr.clone().recipient()))); addr } @@ -536,7 +536,7 @@ impl Handler for HttpServer }; for worker in &self.workers { let tx2 = tx.clone(); - let fut = worker.call(StopWorker{graceful: dur}).into_actor(self); + let fut = worker.send(StopWorker{graceful: dur}).into_actor(self); ActorFuture::then(fut, move |_, slf, _| { slf.workers.pop(); if slf.workers.is_empty() { @@ -544,7 +544,7 @@ impl Handler for HttpServer // we need to stop system if server was spawned if slf.exit { - Arbiter::system().send(actix::msgs::SystemExit(0)) + Arbiter::system().do_send(actix::msgs::SystemExit(0)) } } actix::fut::ok(()) @@ -557,7 +557,7 @@ impl Handler for HttpServer } else { // we need to stop system if server was spawned if self.exit { - Arbiter::system().send(actix::msgs::SystemExit(0)) + Arbiter::system().do_send(actix::msgs::SystemExit(0)) } Response::reply(Ok(())) } diff --git a/src/server/worker.rs b/src/server/worker.rs index 34c5324f..23e8a6c6 100644 --- a/src/server/worker.rs +++ b/src/server/worker.rs @@ -78,14 +78,14 @@ impl Worker { let num = slf.settings.num_channels(); if num == 0 { let _ = tx.send(true); - Arbiter::arbiter().send(StopArbiter(0)); + Arbiter::arbiter().do_send(StopArbiter(0)); } else if let Some(d) = dur.checked_sub(time::Duration::new(1, 0)) { slf.shutdown_timeout(ctx, tx, d); } else { info!("Force shutdown http worker, {} connections", num); slf.settings.head().traverse::(); let _ = tx.send(false); - Arbiter::arbiter().send(StopArbiter(0)); + Arbiter::arbiter().do_send(StopArbiter(0)); } }); } diff --git a/src/test.rs b/src/test.rs index 48c1d950..29f01ab3 100644 --- a/src/test.rs +++ b/src/test.rs @@ -165,7 +165,7 @@ impl TestServer { /// Stop http server fn stop(&mut self) { if let Some(handle) = self.thread.take() { - self.server_sys.send(msgs::SystemExit(0)); + self.server_sys.do_send(msgs::SystemExit(0)); let _ = handle.join(); } } diff --git a/src/ws/client.rs b/src/ws/client.rs index 4201c20e..ebb2f384 100644 --- a/src/ws/client.rs +++ b/src/ws/client.rs @@ -200,7 +200,7 @@ impl WsClient { // get connection and start handshake Ok(Box::new( - self.conn.call(Connect(request.uri().clone())) + self.conn.send(Connect(request.uri().clone())) .map_err(|_| WsClientError::Disconnected) .and_then(|res| match res { Ok(stream) => Either::A(WsHandshake::new(stream, request)), diff --git a/tests/test_server.rs b/tests/test_server.rs index 6c784ca9..e84c9211 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -72,12 +72,12 @@ fn test_start() { assert!(reqwest::get(&format!("http://{}/", addr)).unwrap().status().is_success()); // pause - let _ = srv_addr.call(server::PauseServer).wait(); + let _ = srv_addr.send(server::PauseServer).wait(); thread::sleep(time::Duration::from_millis(100)); assert!(net::TcpStream::connect(addr).is_err()); // resume - let _ = srv_addr.call(server::ResumeServer).wait(); + let _ = srv_addr.send(server::ResumeServer).wait(); assert!(reqwest::get(&format!("http://{}/", addr)).unwrap().status().is_success()); }