Commit Graph

74 Commits

Author SHA1 Message Date
Tim Kuehn
b661ff0175 Complete ClientFuture on error. 2016-09-30 15:36:55 -04:00
Tim Kuehn
b880d65f44 Merge branch 'framed' of github.com:tikue/tarpc into framed 2016-09-30 15:19:16 -04:00
Tim Kuehn
451b99b92a Remove all remaining #[inline]s. 2016-09-30 15:16:29 -04:00
Tim Kuehn
99b13ae6fc Remove an unnecessary Box 2016-09-28 00:04:58 -07:00
Tim Kuehn
5bace01f2b Finish the multiplex implementation 2016-09-26 23:44:22 -07:00
Tim Kuehn
4a63064cbd Remove some panics, and don't use ToSocketAddrs in async methods. 2016-09-19 00:16:47 -07:00
Tim Kuehn
3eb57d4009 Move the static remote to the default reactor core to the crate root.
It didn't really make sense in the framed module, which doesn't care about such things.
2016-09-17 18:31:08 -07:00
Tim Kuehn
14c97b61f9 Rename things to align with tokio changes. 2016-09-17 18:23:35 -07:00
Tim Kuehn
20d1a019ae WIP multiplex Parse/Serialize/FramedIo impls 2016-09-17 12:50:48 -07:00
Tim Kuehn
8c0181633d Track crates.io deps 2016-09-14 10:11:28 -07:00
Tim Kuehn
1c318182c4 Don't serialize on a thread pool 2016-09-14 01:54:03 -07:00
Tim
e8902c21a2 Mangle a lot of names in macro expansion. (#53)
* Mangle a lot of names in macro expansion.

To lower the chance of any issues, prefix idents in service expansion with __tarpc_service.
In future_enum, prefix with __future_enum. The pattern is basically __macro_name_ident.

Any imported enum variant will conflict with a let binding or a function arg, so we basically
can't use any generic idents at all. Example:

    enum Req { request(..) }
    use self::Req::request;

    fn make_request(request: Request) { ... }

                    ^^^^^^^ conflict here

Additionally, suffix generated associated types with Fut to avoid conflicts with camelcased rpcs.
Why someone would do that, I don't know, but we shouldn't allow that wart.

* Trim long macro lines
2016-09-14 01:34:35 -07:00
Tim
be5f55c5f6 Extend snake_to_camel plugin to replace {} in the doc string with the original snake-cased ident. (#50)
* Extend snake_to_camel plugin to replace {} in the doc string with the origin snake-cased ident.

Also, track tokio-rs master.

This is really ad-hoc, undiscoverable, and unintuitive, but there's no way to programmatically create doc strings
in regular code, and I want to produce better doc strings for the associated types.

Given `fn foo_bar`:

Before: `/// The type of future returned by the function of the same name.`
After: ``/// The type of future returned by `{}`.``
    => `/// The type of future returned by foo_bar.`

* Fix some docs

* Use a helper fn on pipeline::Frame instead of handrolled match.

* Don't hide docs for ClientFuture.

It's exposed in the Connect impl of FutureService -- the tradeoff for not generating *another* item -- and hiding it breaks doc links.

* Formatting

* Rename snake_to_camel plugin => tarpc-plugins

* Update README

* Mangle a lot of names in macro expansion.

To lower the chance of any issues, prefix idents in service expansion with __tarpc_service.
In future_enum, prefix with __future_enum. The pattern is basically __macro_name_ident.

Any imported enum variant will conflict with a let binding or a function arg, so we basically
can't use any generic idents at all. Example:

    enum Req { request(..) }
    use self::Req::request;

    fn make_request(request: Request) { ... }

                    ^^^^^^^ conflict here

Additionally, suffix generated associated types with Fut to avoid conflicts with camelcased rpcs.
Why someone would do that, I don't know, but we shouldn't allow that wart.
2016-09-14 01:19:24 -07:00
Tim
54017839d1 Remove an unused trait and a few unnecessary Send bounds (#54) 2016-09-13 21:35:05 -07:00
Adam Wright
b5f2fe5f4f Merge pull request #51 from tikue/client-side-request
Use cleverness to declare the client-side request enum inside a fn.
2016-09-13 18:02:04 -07:00
Tim Kuehn
b5e472b374 Use the new serde_derive crate. 2016-09-06 16:11:32 -07:00
Tim Kuehn
8d561d21b2 Use cleverness to declare the client-side request enum inside a fn.
Previously, the enum couldn't be declared in the fn it was used in, because
they were part of the same repeating pattern in the macro syntax, and you can't
nest the same repeating pattern. I fixed this by expanding it early,
as a macro argument separate from the repeating fn pattern.
2016-09-06 03:54:02 -07:00
Tim
ab6e829ddd Remove two unused errors. 2016-09-04 19:03:52 -07: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
6141b295d1 Add a tarpc_examples package 2016-01-11 23:39:58 -08:00
Tim Kuehn
6a484c48c5 Obfuscate types internal to the generated module to reduce risk of collision with imports.
We don't support imports in the macro yet, but this commit will prevent problems when we do.
2016-01-11 22:54:53 -08:00
Tim Kuehn
1544712bc4 Move protocol::Error and protocol::Result to crate root 2016-01-11 22:39:46 -08:00
Tim Kuehn
6f634c50cc Add doc comment to generated module 2016-01-11 20:10:31 -08:00
Tim Kuehn
0256dc1c1a A few comments on macros 2016-01-11 00:56:40 -08:00
Tim Kuehn
212f0bb7aa Fix issue where service fns with no args would cause compile errors 2016-01-11 00:51:24 -08:00
Tim Kuehn
dca55d4310 Make the generated rpc module public 2016-01-10 18:39:33 -08:00
Tim Kuehn
0f5ef5f575 Move macros crate into a module in tarpc crate 2016-01-10 15:48:32 -08:00
Tim Kuehn
82cc7b3303 Fix tests 2016-01-10 15:01:40 -08:00
Tim Kuehn
87f71b5549 Document all public items and deny(missing_docs) 2016-01-10 14:27:19 -08:00
Adam Wright
56bd362fb1 Modify serve_async to expose the bound address
serve_async was taking a SocketAddr, and then binding to it. This is fine if
your'e always sure of the exact address you want to bind to, but in some cases
you don't know.

One such case is when you want the OS to assign you and ephemeral port number,
like we do in our tests. In this case, you pass 0.0.0.0:0 as the address, and
then call bind. After that, you don't know which address the listener bound to,
so we can't make the subsequent call to TcpStream::connect without getting a
weird error.

This is fixed by the ServeHandle object exposing a local_addr() method, which
returns the address that the listener bound to.
2016-01-10 02:29:06 -08:00
Tim Kuehn
fae09e3fed Fix doc test 2016-01-09 14:44:30 -08:00
Adam Wright
5e34e32094 Generate an unused enum variant to fix a compiler error
Previously if you made a service with a single rpc it would generate an error
because of a redundant match statement.
2016-01-09 14:26:02 -08:00
Tim Kuehn
3bf2d1f16d Fix syntax and add doc comments to public items created in the macro 2016-01-09 14:24:16 -08:00
Tim Kuehn
7c89df7b09 Rustfmt 2016-01-09 14:23:55 -08:00
Tim Kuehn
b17b8c60d4 Remove failed requests from requests map. Fix #14. 2016-01-09 13:02:23 -08:00
Tim Kuehn
195cb4235d Rename wtf method 2016-01-09 12:48:21 -08:00
Tim Kuehn
98a34e4256 printlns => logging 2016-01-09 12:45:16 -08:00
Tim Kuehn
8567b9b845 Make macro easier to read 2016-01-09 04:52:12 -08:00
Tim Kuehn
40b0aecec1 Fix failing tests 2016-01-09 04:43:59 -08:00
Tim Kuehn
e32ef30c8d Warn if an error occurs when disconnecting client from server 2016-01-09 04:33:55 -08:00
Adam Wright
cb63166b82 Remove some stupid whitespace 2016-01-09 04:17:00 -08:00
Adam Wright
c352ff12b4 we tarpc_macros now 2016-01-09 04:00:02 -08:00
Adam Wright
2d9964293e Implement drop for tarpc::Client 2016-01-09 03:57:46 -08:00
Adam Wright
a63c935a33 modify macros to use tarpc:: stuff 2016-01-09 03:42:40 -08:00
Adam Wright
2f324f1689 Remove silly requirement of clone for fn rpc 2016-01-09 03:01:59 -08:00
Adam Wright
9d2a878f88 Merge branch 'macro' 2016-01-09 02:13:58 -08:00
Adam Wright
e0f9c89c0e Make handle_conn be private 2016-01-09 02:13:44 -08:00
Adam Wright
096cf25824 Remove commented code 2016-01-09 01:34:25 -08:00
Adam Wright
2f1b8e931d Clean up warnings 2016-01-09 01:34:08 -08:00
Tim Kuehn
b1e12d6b54 Merge branch 'master' of ssh://git.adam-wright.net:10022/shaladdle/adamrpc-rs 2016-01-09 01:23:22 -08:00