From d4bc3294a35dfb74da03242079b0ec97c09a5f07 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 27 Jan 2018 10:04:56 -0800 Subject: [PATCH] actix compatibility --- Cargo.toml | 3 ++- src/context.rs | 36 +++++------------------------------- src/server/srv.rs | 6 ++++-- src/ws/context.rs | 36 +++++------------------------------- 4 files changed, 16 insertions(+), 65 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68db2d68..07ffafa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,8 @@ openssl = { version="0.10", optional = true } tokio-openssl = { version="0.2", optional = true } [dependencies.actix] -version = "^0.4.5" +#version = "^0.4.6" +git = "https://github.com/actix/actix.git" [dev-dependencies] env_logger = "0.5" diff --git a/src/context.rs b/src/context.rs index cdeb43d1..1702c8c3 100644 --- a/src/context.rs +++ b/src/context.rs @@ -6,13 +6,12 @@ use futures::unsync::oneshot; use smallvec::SmallVec; use actix::{Actor, ActorState, ActorContext, AsyncContext, - Address, SyncAddress, Handler, Subscriber, ResponseType, SpawnHandle}; + Address, SyncAddress, Handler, ResponseType, MessageResult, SpawnHandle}; use actix::fut::ActorFuture; -use actix::dev::{queue, AsyncContextApi, - ContextImpl, ContextProtocol, Envelope, ToEnvelope, RemoteEnvelope}; +use actix::dev::{AsyncContextApi, ContextImpl, Envelope, ToEnvelope, RemoteEnvelope}; use body::{Body, Binary}; -use error::{Error, Result, ErrorInternalServerError}; +use error::{Error, ErrorInternalServerError}; use httprequest::HttpRequest; @@ -86,10 +85,6 @@ impl AsyncContext for HttpContext where A: Actor #[doc(hidden)] impl AsyncContextApi for HttpContext where A: Actor { - #[inline] - fn unsync_sender(&mut self) -> queue::unsync::UnboundedSender> { - self.inner.unsync_sender() - } #[inline] fn unsync_address(&mut self) -> Address { self.inner.unsync_address() @@ -174,26 +169,6 @@ impl HttpContext where A: Actor { } } -impl HttpContext where A: Actor { - - #[inline] - #[doc(hidden)] - pub fn subscriber(&mut self) -> Box> - where A: Handler, M: ResponseType + 'static - { - self.inner.subscriber() - } - - #[inline] - #[doc(hidden)] - pub fn sync_subscriber(&mut self) -> Box + Send> - where A: Handler, - M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send, - { - self.inner.sync_subscriber() - } -} - impl ActorHttpContext for HttpContext where A: Actor, S: 'static { #[inline] @@ -229,12 +204,11 @@ impl ToEnvelope for HttpContext where A: Actor>, { #[inline] - fn pack(msg: M, tx: Option>>, - channel_on_drop: bool) -> Envelope + fn pack_msg(msg: M, tx: Option>>) -> Envelope where A: Handler, M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send { - RemoteEnvelope::new(msg, tx, channel_on_drop).into() + RemoteEnvelope::envelope(msg, tx).into() } } diff --git a/src/server/srv.rs b/src/server/srv.rs index e000c2f0..47309e70 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -313,7 +313,8 @@ impl HttpServer // start http server actor let signals = self.subscribe_to_signals(); let addr: SyncAddress<_> = Actor::start(self); - signals.map(|signals| signals.send(signal::Subscribe(addr.subscriber()))); + signals.map(|signals| signals.send( + signal::Subscribe(addr.clone().into_subscriber()))); addr } } @@ -478,7 +479,8 @@ impl HttpServer, A, H, U> move |(t, _)| Conn{io: WrapperStream::new(t), peer: None, http2: false})); self }); - signals.map(|signals| signals.send(signal::Subscribe(addr.subscriber()))); + signals.map(|signals| signals.send( + signal::Subscribe(addr.clone().into_subscriber()))); addr } } diff --git a/src/ws/context.rs b/src/ws/context.rs index 2ad164b4..001b9018 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -5,13 +5,12 @@ use futures::unsync::oneshot; use smallvec::SmallVec; use actix::{Actor, ActorState, ActorContext, AsyncContext, - Address, SyncAddress, Handler, Subscriber, ResponseType, SpawnHandle}; + Address, SyncAddress, Handler, ResponseType, SpawnHandle, MessageResult}; use actix::fut::ActorFuture; -use actix::dev::{queue, AsyncContextApi, - ContextImpl, ContextProtocol, Envelope, ToEnvelope, RemoteEnvelope}; +use actix::dev::{AsyncContextApi, ContextImpl, Envelope, ToEnvelope, RemoteEnvelope}; use body::{Body, Binary}; -use error::{Error, Result, ErrorInternalServerError}; +use error::{Error, ErrorInternalServerError}; use httprequest::HttpRequest; use context::{Frame as ContextFrame, ActorHttpContext, Drain}; @@ -69,10 +68,6 @@ impl AsyncContext for WebsocketContext where A: Actor AsyncContextApi for WebsocketContext where A: Actor { - #[inline] - fn unsync_sender(&mut self) -> queue::unsync::UnboundedSender> { - self.inner.unsync_sender() - } #[inline] fn unsync_address(&mut self) -> Address { @@ -198,26 +193,6 @@ impl WebsocketContext where A: Actor { } } -impl WebsocketContext where A: Actor { - - #[inline] - #[doc(hidden)] - pub fn subscriber(&mut self) -> Box> - where A: Handler, M: ResponseType + 'static - { - self.inner.subscriber() - } - - #[inline] - #[doc(hidden)] - pub fn sync_subscriber(&mut self) -> Box + Send> - where A: Handler, - M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send, - { - self.inner.sync_subscriber() - } -} - impl ActorHttpContext for WebsocketContext where A: Actor, S: 'static { #[inline] @@ -253,11 +228,10 @@ impl ToEnvelope for WebsocketContext where A: Actor>, { #[inline] - fn pack(msg: M, tx: Option>>, - channel_on_drop: bool) -> Envelope + fn pack_msg(msg: M, tx: Option>>) -> Envelope where A: Handler, M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send { - RemoteEnvelope::new(msg, tx, channel_on_drop).into() + RemoteEnvelope::envelope(msg, tx).into() } }