diff --git a/tower/Cargo.toml b/tower/Cargo.toml index bf3e36c..f8c7120 100644 --- a/tower/Cargo.toml +++ b/tower/Cargo.toml @@ -13,22 +13,40 @@ clients and servers. categories = ["asynchronous", "network-programming"] keywords = ["io", "async", "non-blocking", "futures", "service"] +[features] +default = ["layers", "make_service"] +layers = [ + "tower-buffer", + "tower-in-flight-limit", + "tower-load-shed", + "tower-rate-limit", + "tower-retry", + "tower-filter" +] +make_service = [ + "tower-balance", + "tower-discover", + "tower-reconnect" +] + [dependencies] futures = "0.1" -tower-service = "0.2.0" -tower-layer = { version = "0.1", path = "../tower-layer" } +tower-service = "0.2" tower-service-util = { version = "0.1.0", path = "../tower-service-util", features = ["io", "either"] } +tower-layer = { version = "0.1", path = "../tower-layer" } +tower-in-flight-limit = { version = "0.1", path = "../tower-in-flight-limit", optional = true } +tower-rate-limit = { version = "0.1", path = "../tower-rate-limit", optional = true } +tower-retry = { version = "0.1", path = "../tower-retry", optional = true } +tower-buffer = { version = "0.1", path = "../tower-buffer", optional = true } +tower-filter = { version = "0.1", path = "../tower-filter", optional = true } +tower-load-shed = { version = "0.1", path = "../tower-load-shed", optional = true } +tower-balance = { version = "0.1", path = "../tower-balance", optional = true } +tower-discover = { version = "0.1", path = "../tower-discover", optional = true } +tower-reconnect = { version = "0.1", path = "../tower-reconnect", optional = true } [dev-dependencies] futures = "0.1" -tower-service = "0.2" -tower-in-flight-limit = { version = "0.1", path = "../tower-in-flight-limit" } -tower-rate-limit = { version = "0.1", path = "../tower-rate-limit" } -tower-reconnect = { version = "0.1", path = "../tower-reconnect" } -tower-retry = { version = "0.1", path = "../tower-retry" } -tower-buffer = { version = "0.1", path = "../tower-buffer" } tower-hyper = { git = "https://github.com/tower-rs/tower-hyper" } -tower-layer = { version = "0.1", path = "../tower-layer" } tokio-tcp = "0.1" hyper = "0.12" log = "0.4.1" @@ -36,5 +54,4 @@ tokio = "0.1" env_logger = { version = "0.5.3", default-features = false } tokio-timer = "0.1" futures-cpupool = "0.1" -tokio-mock-task = "0.1" void = "1" diff --git a/tower/src/layer.rs b/tower/src/layer.rs new file mode 100644 index 0000000..12d53a4 --- /dev/null +++ b/tower/src/layer.rs @@ -0,0 +1,8 @@ +//! A collection of `Layer` based tower services + +pub use tower_buffer::BufferLayer; +pub use tower_filter::FilterLayer; +pub use tower_in_flight_limit::InFlightLimitLayer; +pub use tower_load_shed::LoadShedLayer; +pub use tower_rate_limit::RateLimitLayer; +pub use tower_retry::RetryLayer; diff --git a/tower/src/lib.rs b/tower/src/lib.rs index f9b7e8b..9d0ab22 100644 --- a/tower/src/lib.rs +++ b/tower/src/lib.rs @@ -1,14 +1,37 @@ //! Various utility types and functions that are generally with Tower. -pub mod builder; #[macro_use] extern crate futures; -#[cfg(test)] -extern crate tokio_mock_task; + extern crate tower_layer; extern crate tower_service; extern crate tower_service_util; +#[cfg(feature = "layers")] +extern crate tower_buffer; +#[cfg(feature = "layers")] +extern crate tower_filter; +#[cfg(feature = "layers")] +extern crate tower_in_flight_limit; +#[cfg(feature = "layers")] +extern crate tower_load_shed; +#[cfg(feature = "layers")] +extern crate tower_rate_limit; +#[cfg(feature = "layers")] +extern crate tower_retry; + +#[cfg(feature = "make_service")] +extern crate tower_balance; +#[cfg(feature = "make_service")] +extern crate tower_discover; +#[cfg(feature = "make_service")] +extern crate tower_reconnect; + +pub mod builder; +#[cfg(feature = "layers")] +pub mod layer; +#[cfg(feature = "make_service")] +pub mod make_service; pub mod util; pub use builder::ServiceBuilder; diff --git a/tower/src/make_service.rs b/tower/src/make_service.rs new file mode 100644 index 0000000..8984eaa --- /dev/null +++ b/tower/src/make_service.rs @@ -0,0 +1,5 @@ +//! A collection of tower `MakeService` based utilities + +pub use tower_balance::{load, Balance, Choose, Load, Pool}; +pub use tower_discover::Discover; +pub use tower_reconnect::Reconnect; diff --git a/tower/src/util/mod.rs b/tower/src/util/mod.rs index bdf6892..e56da3b 100644 --- a/tower/src/util/mod.rs +++ b/tower/src/util/mod.rs @@ -1,9 +1,5 @@ //! Combinators for working with `Service`s -use futures::{IntoFuture, Stream}; -use tower_service::Service; -use tower_service_util::CallAll; - mod and_then; mod apply; mod from_err; @@ -24,9 +20,15 @@ pub use self::then::Then; // `tower-service-util` re-exports pub use tower_service_util::BoxService; +pub use tower_service_util::CallAll; +pub use tower_service_util::CallAllUnordered; pub use tower_service_util::EitherService; pub use tower_service_util::OptionService; pub use tower_service_util::ServiceFn; +pub use tower_service_util::UnsyncBoxService; + +use futures::{IntoFuture, Stream}; +use tower_service::Service; impl ServiceExt for T where T: Service {}