Skip to content

Commit

Permalink
Refactor server module.
Browse files Browse the repository at this point in the history
In the interest of the user's attention, some ancillary APIs have been
moved to new submodules:

- server::limits contains what was previously called Throttler and
  ChannelFilter. Both of those names were very generic, when the methods
  applied by these types were very specific (and also simplistic). Renames
  have occurred:
  - ThrottlerStream => MaxRequestsPerChannel
  - Throttler => MaxRequests
  - ChannelFilter => MaxChannelsPerKey
- server::incoming contains the Incoming trait.
- server::tokio contains the tokio-specific helper types.

The 5 structs and 1 enum remaining in the base server module are all
core to the functioning of the server.
  • Loading branch information
tikue committed Apr 22, 2021
1 parent eb67c54 commit ea7b676
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 239 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ This example uses [tokio](https://tokio.rs), so add the following dependencies t
your `Cargo.toml`:

```toml
anyhow = "1.0"
futures = "1.0"
tarpc = { version = "0.26", features = ["tokio1"] }
tokio = { version = "1.0", features = ["macros"] }
Expand All @@ -99,9 +100,8 @@ use futures::{
};
use tarpc::{
client, context,
server::{self, Incoming},
server::{self, incoming::Incoming},
};
use std::io;

// This is the service definition. It looks a lot like a trait definition.
// It defines one RPC, hello, which takes one arg, name, and returns a String.
Expand Down Expand Up @@ -140,7 +140,7 @@ available behind the `tcp` feature.

```rust
#[tokio::main]
async fn main() -> io::Result<()> {
async fn main() -> anyhow::Result<()> {
let (client_transport, server_transport) = tarpc::transport::channel::unbounded();

let server = server::BaseChannel::with_defaults(server_transport);
Expand Down
2 changes: 1 addition & 1 deletion example-service/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
};
use tarpc::{
context,
server::{self, Channel, Incoming},
server::{self, incoming::Incoming, Channel},
tokio_serde::formats::Json,
};
use tokio::time;
Expand Down
2 changes: 1 addition & 1 deletion tarpc/examples/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use futures::{future, prelude::*};
use std::env;
use tarpc::{
client, context,
server::{BaseChannel, Incoming},
server::{incoming::Incoming, BaseChannel},
};
use tokio_serde::formats::Json;
use tracing_subscriber::prelude::*;
Expand Down
4 changes: 2 additions & 2 deletions tarpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ where
.map_err(ChannelError::Ready)
}

fn start_send<'a>(
self: &'a mut Pin<&mut Self>,
fn start_send(
self: &mut Pin<&mut Self>,
message: ClientMessage<Req>,
) -> Result<(), ChannelError<C::Error>> {
self.transport_pin_mut()
Expand Down
4 changes: 2 additions & 2 deletions tarpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
//! };
//! use tarpc::{
//! client, context,
//! server::{self, Incoming},
//! server::{self, incoming::Incoming},
//! };
//!
//! // This is the service definition. It looks a lot like a trait definition.
Expand All @@ -111,7 +111,7 @@
//! # };
//! # use tarpc::{
//! # client, context,
//! # server::{self, Incoming},
//! # server::{self, incoming::Incoming},
//! # };
//! # // This is the service definition. It looks a lot like a trait definition.
//! # // It defines one RPC, hello, which takes one arg, name, and returns a String.
Expand Down
Loading

0 comments on commit ea7b676

Please sign in to comment.