Skip to content

Commit

Permalink
Remove deprecated tokio-proto and replace with homegrown rpc framework (
Browse files Browse the repository at this point in the history
#199)

# New Crates

- crate rpc contains the core client/server request-response framework, as well as a transport trait.
- crate bincode-transport implements a transport that works almost exactly as tarpc works today (not to say it's wire-compatible).
- crate trace has some foundational types for tracing. This isn't really fleshed out yet, but it's useful for in-process log tracing, at least.

All crates are now at the top level. e.g. tarpc-plugins is now tarpc/plugins rather than tarpc/src/plugins. tarpc itself is now a *very* small code surface, as most functionality has been moved into the other more granular crates.

# New Features
- deadlines: all requests specify a deadline, and a server will stop processing a response when past its deadline.
- client cancellation propagation: when a client drops a request, the client sends a message to the server informing it to cancel its response. This means cancellations can propagate across multiple server hops.
- trace context stuff as mentioned above
- more server configuration for total connection limits, per-connection request limits, etc.

# Removals
- no more shutdown handle.  I left it out for now because of time and not being sure what the right solution is.
- all async now, no blocking stub or server interface. This helps with maintainability, and async/await makes async code much more usable. The service trait is thusly renamed Service, and the client is renamed Client.
- no built-in transport. Tarpc is now transport agnostic (see bincode-transport for transitioning existing uses).
- going along with the previous bullet, no preferred transport means no TLS support at this time. We could make a tls transport or make bincode-transport compatible with TLS.
- a lot of examples were removed because I couldn't keep up with maintaining all of them. Hopefully the ones I kept are still illustrative.
- no more plugins!

# Open Questions

1. Should client.send() return `Future<Response>` or `Future<Future<Response>>`? The former appears more ergonomic but it doesn’t allow concurrent requests with a single client handle. The latter is less ergonomic but yields back control of the client once it’s successfully sent out the request. Should we offer fns for both?
2. Should rpc service! Fns take &mut self or &self or self? The service needs to impl Clone anyway, technically we only need to clone it once per connection, and then leave it up to the user to decide if they want to clone it per RPC. In practice, everyone doing nontrivial stuff will need to clone it per RPC, I think.
3. Do the request/response structs look ok?
4. Is supporting server shutdown/lameduck important?

Fixes #178 #155 #124 #104 #83 #38
  • Loading branch information
tikue authored Oct 16, 2018
1 parent 5e4b97e commit 905e5be
Show file tree
Hide file tree
Showing 73 changed files with 4,691 additions and 5,144 deletions.
30 changes: 4 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
language: rust
sudo: false

rust:
- nightly
sudo: false
cache: cargo

os:
- osx
- linux

addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev

before_script:
- |
pip install 'travis-cargo<0.2' --user &&
export PATH=$HOME/.local/bin:$PATH
script:
- |
travis-cargo build -- --features tls && travis-cargo test -- --features tls && travis-cargo bench -- --features tls &&
rustdoc --test README.md -L target/debug/deps -L target/debug &&
travis-cargo build && travis-cargo test && travis-cargo bench
after_success:
- travis-cargo coveralls --no-sudo

env:
global:
# override the default `--features unstable` used for the nightly branch
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
- cargo test --all --all-features
64 changes: 9 additions & 55 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,56 +1,10 @@
[package]
name = "tarpc"
version = "0.12.1"
authors = ["Adam Wright <[email protected]>", "Tim Kuehn <[email protected]>"]
license = "MIT"
documentation = "https://docs.rs/tarpc"
homepage = "https://github.com/google/tarpc"
repository = "https://github.com/google/tarpc"
keywords = ["rpc", "network", "server", "api", "tls"]
categories = ["asynchronous", "network-programming"]
readme = "README.md"
description = "An RPC framework for Rust with a focus on ease of use."

[badges]
travis-ci = { repository = "google/tarpc" }

[dependencies]
bincode = "1.0"
byteorder = "1.0"
bytes = "0.4"
cfg-if = "0.1.0"
futures = "0.1.11"
lazy_static = "1.0"
log = "0.4"
net2 = "0.2"
num_cpus = "1.0"
serde = "1.0"
serde_derive = "1.0"
tarpc-plugins = { path = "src/plugins", version = "0.4.0" }
thread-pool = "0.1.1"
tokio-codec = "0.1"
tokio-core = "0.1.6"
tokio-io = "0.1"
tokio-proto = "0.1.1"
tokio-service = "0.1"

# Optional dependencies
native-tls = { version = "0.1", optional = true }
tokio-tls = { version = "0.1", optional = true }

[dev-dependencies]
chrono = "0.4"
env_logger = "0.5"
futures-cpupool = "0.1"
clap = "2.0"
serde_bytes = "0.10"

[target.'cfg(target_os = "macos")'.dev-dependencies]
security-framework = "0.2"

[features]
default = []
tls = ["tokio-tls", "native-tls"]
unstable = ["serde/unstable"]

[workspace]

members = [
"example-service",
"rpc",
"trace",
"bincode-transport",
"tarpc",
"plugins",
]
Loading

0 comments on commit 905e5be

Please sign in to comment.