Skip to content

Commit

Permalink
Remove remaining feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
vorot93 authored and tikue committed Oct 2, 2019
1 parent 46bcc0f commit e910058
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
rust:
- nightly
- beta
sudo: false
cache: cargo

Expand Down
1 change: 1 addition & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ futures-preview = { version = "0.3.0-alpha.18" }
humantime = "1.0"
log = "0.4"
pin-utils = "0.1.0-alpha.4"
raii-counter = "0.2"
rand = "0.7"
tokio-timer = "0.3.0-alpha.4"
trace = { package = "tarpc-trace", version = "0.2", path = "../trace" }
Expand Down
3 changes: 3 additions & 0 deletions rpc/src/client/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ where
context: context::Context {
deadline: dispatch_request.ctx.deadline,
trace_context: dispatch_request.ctx.trace_context,
_non_exhaustive: (),
},
_non_exhaustive: (),
});
self.as_mut().transport().start_send(request)?;
self.as_mut().in_flight_requests().insert(
Expand Down Expand Up @@ -798,6 +800,7 @@ mod tests {
Response {
request_id: 0,
message: Ok("hello".into()),
_non_exhaustive: (),
},
);
block_on(dispatch).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion rpc/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ where
}

/// Settings that control the behavior of the client.
#[non_exhaustive]
#[derive(Clone, Debug)]
pub struct Config {
/// The number of requests that can be in flight at once.
Expand All @@ -114,13 +113,16 @@ pub struct Config {
/// `pending_requests_buffer` controls the size of the channel clients use
/// to communicate with the request dispatch task.
pub pending_request_buffer: usize,
#[doc(hidden)]
_non_exhaustive: (),
}

impl Default for Config {
fn default() -> Self {
Config {
max_in_flight_requests: 1_000,
pending_request_buffer: 100,
_non_exhaustive: (),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion rpc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use trace::{self, TraceId};
/// be different for each request in scope.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct Context {
/// When the client expects the request to be complete by. The server should cancel the request
/// if it is not complete by this time.
Expand All @@ -36,6 +35,8 @@ pub struct Context {
/// include the same `trace_id` as that included on the original request. This way,
/// users can trace related actions across a distributed system.
pub trace_context: trace::Context,
#[doc(hidden)]
pub(crate) _non_exhaustive: (),
}

#[cfg(feature = "serde1")]
Expand All @@ -49,6 +50,7 @@ pub fn current() -> Context {
Context {
deadline: SystemTime::now() + Duration::from_secs(10),
trace_context: trace::Context::new_root(),
_non_exhaustive: (),
}
}

Expand Down
15 changes: 9 additions & 6 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

#![feature(weak_counts, non_exhaustive, trait_alias)]
#![deny(missing_docs, missing_debug_implementations)]

//! An RPC framework providing client and server.
Expand All @@ -31,15 +30,14 @@ pub mod server;
pub mod transport;
pub(crate) mod util;

pub use crate::{client::Client, server::Server, transport::Transport};
pub use crate::{client::Client, server::Server, transport::sealed::Transport};

use futures::task::Poll;
use std::{io, time::SystemTime};

/// A message from a client to a server.
#[derive(Debug)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum ClientMessage<T> {
/// A request initiated by a user. The server responds to a request by invoking a
/// service-provided request handler. The handler completes with a [`response`](Response), which
Expand All @@ -60,36 +58,39 @@ pub enum ClientMessage<T> {
/// The ID of the request to cancel.
request_id: u64,
},
#[doc(hidden)]
_NonExhaustive,
}

/// A request from a client to a server.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct Request<T> {
/// Trace context, deadline, and other cross-cutting concerns.
pub context: context::Context,
/// Uniquely identifies the request across all requests sent over a single channel.
pub id: u64,
/// The request body.
pub message: T,
#[doc(hidden)]
_non_exhaustive: (),
}

/// A response from a server to a client.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct Response<T> {
/// The ID of the request being responded to.
pub request_id: u64,
/// The response body, or an error if the request failed.
pub message: Result<T, ServerError>,
#[doc(hidden)]
_non_exhaustive: (),
}

/// An error response from a server to a client.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct ServerError {
#[cfg_attr(
feature = "serde1",
Expand All @@ -103,6 +104,8 @@ pub struct ServerError {
pub kind: io::ErrorKind,
/// A message describing more detail about the error that occurred.
pub detail: Option<String>,
#[doc(hidden)]
_non_exhaustive: (),
}

impl From<ServerError> for io::Error {
Expand Down
Loading

0 comments on commit e910058

Please sign in to comment.