57 Commits

Author SHA1 Message Date
Tim Kuehn
a41bbf65b2 Use rustfmt instead of cargo fmt so that diff is only printed once 2021-04-01 17:24:34 -07:00
Tim Kuehn
3d7b0171fe Fix cargo fmt portion of pre-commit 2021-03-26 19:39:56 -07:00
Tim Kuehn
72d5dbba89 Cleanup wrap-up.
- Remove unnecessary Sync and Clone bounds.
- Merge client and client::channel modules.
- Run cargo clippy in the pre-push hook.
- Put DispatchResponse.cancellation in an Option.  Previously, the
  cancellation logic looked to see if `complete == true`, but it's a bit
  less error prone to put the Cancellation in an Option, so that the
  request can't accidentally be cancelled.
- Remove some unnecessary pins/projections.
- Clean up docs a bit. rustdoc had some warnings that are now gone.
2021-03-07 22:29:03 -08:00
Tim Kuehn
6f419e9a9a Refactor server module to be easier to understand.
1. Renames

Some of the items in this module were renamed to be less generic:

- Handler => Incoming
- ClientHandler => Requests
- ResponseHandler => InFlightRequest
- Channel::{respond_with => requests}

In the case of Handler: handler of *what*? Now it's a bit clearer that
this is a stream of Channels (aka *incoming* connections).

Similarly, ClientHandler was a stream of requests over a single
connection. Hopefully Requests better reflects that.

ResponseHandler was renamed InFlightRequest because it no longer
contains the serving function. Instead, it is just the request, plus
the response channel and an abort hook. As a result of this,
Channel::respond_with underwent a big change: it used to take the
serving function and return a ClientHandler; now it has been renamed
Channel::requests and does not take any args.

2. Execute methods

All methods thats actually result in responses being generated
have been consolidated into methods named `execute`:

- InFlightRequest::execute returns a future that completes when a
  response has been generated and sent to the server Channel.
- Requests::execute automatically spawns response handlers for all
  requests over a single channel.
- Channel::execute is a convenience for `channel.requests().execute()`.
- Incoming::execute automatically spawns response handlers for all
  requests over all channels.

3. Removal of Server.

server::Server was removed, as it provided no value over the Incoming/Channel
abstractions. Additionally, server::new was removed, since it just
returned a Server.
2021-03-06 20:20:48 -08:00
Tim Kuehn
3207affb4a Update pre-commit for changes to cargo fmt.
--write-mode is now --check.
2020-08-19 17:51:20 -07:00
Tim Kuehn
e0674cd57f Make pre-push run on rust stable. 2019-12-19 12:06:06 -08:00
Tim Kuehn
8250ca31ff Remove --no-default-features from pre-push hook.
It seemingly doesn't work at the root of a virtual workspace. Not sure if this is new behavior or just a new explicit error message.
2019-11-15 17:19:08 -08:00
Tim Kuehn
f8ba7d9f4e Make tokio1 serde1 default features 2019-08-08 22:06:09 -07:00
Tim Kuehn
abb0b5b3ac Rewrite to use proc_macro_attribute 2019-07-29 22:04:04 -07:00
Tyler Bindon
959bb691cd Update regex to match diffs output by cargo fmt. (#208)
It appears the header of the diffs output by cargo fmt have changed. It now says "Diff in /blah/blah/blah.rs at line 99:" Matching on lines starting with + or - should be more future-proof against changes to the surroundings.
2018-12-09 01:59:35 -08:00
Tim
905e5be8bb Remove deprecated tokio-proto and replace with homegrown rpc framework (#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
2018-10-16 11:26:27 -07:00
Tim
5e3cf3c807 Run the new nightly cargo fmt (#156) 2017-07-18 14:54:46 -07:00
Adam Wright
3eec8fe1dd Actually fail the prepush in try_run 2017-02-20 18:10:23 -08:00
Adam Wright
9c973eb80b Switch back to verb_ing_ 2017-02-20 18:07:36 -08:00
Adam Wright
37763f25e4 Make whitespace consistent 2017-02-20 17:46:13 -08:00
Adam Wright
515ab90299 Various simplifications/improvements to pre-push 2017-02-20 17:44:30 -08:00
Adam Wright
9987eae290 --color=always has to be after the command 2017-02-20 17:11:05 -08:00
Adam Wright
22545c653c Fix prepush script? 2017-02-20 17:11:05 -08:00
Tim Kuehn
c7831e8aa6 More spacing stuff 2017-02-16 20:56:04 -08:00
Tim Kuehn
8faba59d66 Fix tabs in pre-push, and remove dead code in readme 2017-02-16 20:51:57 -08:00
Tim Kuehn
eac6b64aeb Merge branch 'master' of github.com:google/tarpc into doc-fix 2017-02-16 17:52:21 -08:00
Tim Kuehn
7ae107cf2b Fix readme for real this time. 2017-02-16 17:46:55 -08:00
Tim Kuehn
4fc37fe707 Add bench to pre-push and .travis.yml 2017-02-16 00:56:38 -08:00
compressed
fafe569ebc Add TLS support (#81)
When `-- features tls` is specified for tarpc, RPC communication can
also occur over a `TlsStream<TcpStream>` instead of a `TcpStream`.

* The functional tests have been refactored to use a common set of
functions for constructing the client and server structs so that all
the tests are shared across non-tls and tls test runs.

* Update pre-push to test TLS

* The `cfg_attr` logic caused many false warnings from clippy, so for now the crate docs for TLS are not tested.
2017-01-31 10:21:13 -08:00
Tim
7aabfb3c14 Rewrite using tokio (#44)
* Rewrite tarpc on top of tokio.

* Add examples

* Move error types to their own module.

Also, cull unused error variants.

* Remove unused fn

* Remove CanonicalRpcError* types. They're 100% useless.

* Track tokio master (WIP)

* The great error revamp.

Removed the canonical rpc error type. Instead, the user declares
the error type for each rpc:

In the above example, the error type is Baz. Declaring an error is
optional; if none is specified, it defaults to Never, a convenience
struct that wraps the never type (exclamation mark) to impl Serialize, Deserialize,
Error, etc. Also adds the convenience type StringError for easily
using a String as an error type.

* Add missing license header

* Minor cleanup

* Rename StringError => Message

* Create a sync::Connect trait.

Along with this, the existing Connect trait moves to future::Connect. The future
and sync modules are reexported from the crate root.

Additionally, the utility errors Never and Message are no longer reexported from
the crate root.

* Update readme

* Track tokio/futures master. Add a Spawn utility trait to replace the removed forget.

* Fix pre-push hook

* Add doc comment to SyncServiceExt.

* Fix up some documentation

* Track tokio-proto master

* Don't set tcp nodelay

* Make future::Connect take an associated type for the future.

* Unbox FutureClient::connect return type

* Use type alias instead of newtype struct for ClientFuture

* Fix benches/latency.rs

* Write a plugin to convert lower_snake_case idents/types to UpperCamelCase.

Use it to add associated types to FutureService instead of boxing the return futures.

* Specify plugin = true in snake_to_camel/Cargo.toml. Weird things happen otherwise.

* Add clippy.toml
2016-09-04 16:09:50 -07:00
Tim Kuehn
1cc8cbcdc3 Update pre-push to use rustup in lieu of multirust, because rustup is #thefuture. 2016-04-24 17:48:29 -07:00
Tim Kuehn
e8fcf0e4de Fix issue with grep exit status 2016-02-27 02:30:39 -08:00
Tim Kuehn
a8766a9200 Use rustfmt --write-mode=diff in lieu of hashes 2016-02-25 00:50:46 -08:00
Tim Kuehn
ef96c87226 Skip children when rustfmting in pre-commit 2016-02-25 00:50:37 -08:00
Tim Kuehn
3543b34f2b Fix formatting check.
* shasum suffixes the checksum with '- filename' so pipe in the text instead.
* rustfmt prefixes the formatting with 'Using rustfmt config file filename' so pipe in the text instead.
2016-02-25 00:50:29 -08:00
Adam Wright
06a2cab31c Move /bin/bash to the top so it works 2016-02-19 23:08:50 -08:00
Adam Wright
4ed127b39e NOT FOUND instead of FAILED 2016-02-19 21:31:11 -08:00
Adam Wright
d0e9693263 Be consistent with function declarations 2016-02-18 01:40:44 -08:00
Adam Wright
6d23174219 Build on nightly too, as per review comment 2016-02-18 01:36:39 -08:00
Adam Wright
a06b583334 Also check existence of shasum 2016-02-18 01:27:07 -08:00
Adam Wright
82762583be Change colors a bit, only exit when check_toolchain fails.. 2016-02-18 01:06:31 -08:00
Adam Wright
3462451256 Check for multirust, rustfmt, clean up some things 2016-02-18 01:06:31 -08:00
Adam Wright
17d800b8a8 Update comments 2016-02-18 01:06:31 -08:00
Adam Wright
403eba201b Group builds/tests by toolchain for speed 2016-02-18 01:06:31 -08:00
Adam Wright
f2328d200e pre-commit doesn't modify files, just checks foramtting 2016-02-18 01:06:31 -08:00
Adam Wright
07c052a1c1 Individually format crates, use -q 2016-02-15 18:54:15 -08:00
Adam Wright
34cf0c8172 Updated hook to print messages like prepush 2016-02-15 18:30:26 -08:00
Adam Wright
7b196400b8 Revamp push hook
1. Create environment variables for options
3. Use multirust to test different toolchains. If multirust isn't
   installed, use current toolchain.
2016-02-15 17:28:16 -08:00
Adam Wright
e2756edd72 Test all crates and format on pre-commit 2016-02-15 13:58:04 -08:00
Tim Kuehn
a58dea0ec5 Update license from dual Apache 2.0/MIT to just MIT. 2016-02-08 11:52:51 -08:00
Adam Wright
14ef89bbca Change the commit hook to print something while its running tests 2016-01-24 17:29:38 -08:00
Tim Kuehn
9bd7fc6711 Add missing license headers 2016-01-21 11:27:37 -08:00
Adam Wright
6e37d3a37e Fix pre-push/commit hooks so they work.
- Move them back to the root directory of the repo
- Explicitly specify the path to the manifest we are running tests for
2016-01-12 23:35:53 -08:00
Tim Kuehn
6141b295d1 Add a tarpc_examples package 2016-01-11 23:39:58 -08:00
Adam Wright
1e42547ca4 Remove crap we don't need, actually fail on test result 2016-01-10 18:01:21 -08:00