Skip to content
Snippets Groups Projects
Commit 1005cde2 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Yaroslav Dynnikov
Browse files

rename: trait rpc::Request -> rpc::RequestArgs

parent 81799af9
No related branches found
No related tags found
1 merge request!619Refactor/network improvements
......@@ -22,7 +22,7 @@ pub mod update_instance;
/// Types implementing this trait represent an RPC's (remote procedure call)
/// arguments. This trait contains information about the request.
pub trait Request: Encode + DecodeOwned {
pub trait RequestArgs: Encode + DecodeOwned {
/// Remote procedure name.
const PROC_NAME: &'static str;
......@@ -33,7 +33,7 @@ pub trait Request: Encode + DecodeOwned {
/// Invoke remote procedure call on an instance specified by `address`.
pub async fn network_call<R>(address: &str, request: &R) -> ::tarantool::Result<R::Response>
where
R: Request,
R: RequestArgs,
{
// TODO: move address parsing into client
let (address, port) = address.rsplit_once(':').ok_or_else(|| {
......@@ -53,7 +53,7 @@ where
/// Invoke remote procedure call on a Raft leader.
pub async fn network_call_to_leader<R>(request: &R) -> Result<R::Response>
where
R: Request,
R: RequestArgs,
{
let node = node::global()?;
let leader_id = node.status().leader_id.ok_or(Error::LeaderUnknown)?;
......@@ -100,7 +100,7 @@ macro_rules! define_rpc_request {
$({ $($res_named_fields)* })?
$(( $($res_unnamed_fields)* );)?
impl $crate::rpc::Request for $request {
impl $crate::rpc::RequestArgs for $request {
const PROC_NAME: &'static str = $crate::stringify_cfunc!($proc);
type Response = $response;
}
......
......@@ -52,7 +52,7 @@ pub struct WaitVclockRpc {
impl Encode for WaitVclockRpc {}
impl rpc::Request for WaitVclockRpc {
impl rpc::RequestArgs for WaitVclockRpc {
const PROC_NAME: &'static str = crate::stringify_cfunc!(proc_wait_vclock);
type Response = (Vclock,);
}
......@@ -125,7 +125,7 @@ pub struct ReadIndexRpc {
impl Encode for ReadIndexRpc {}
impl rpc::Request for ReadIndexRpc {
impl rpc::RequestArgs for ReadIndexRpc {
const PROC_NAME: &'static str = crate::stringify_cfunc!(proc_read_index);
type Response = (RaftIndex,);
}
......@@ -152,7 +152,7 @@ pub struct WaitIndexRpc {
impl Encode for WaitIndexRpc {}
impl rpc::Request for WaitIndexRpc {
impl rpc::RequestArgs for WaitIndexRpc {
const PROC_NAME: &'static str = crate::stringify_cfunc!(proc_wait_index);
type Response = (RaftIndex,);
}
......
......@@ -238,7 +238,7 @@ impl PoolWorker {
/// - in case peer responded with an error
pub fn rpc<R>(&mut self, request: &R, cb: impl FnOnce(Result<R::Response>) + 'static)
where
R: rpc::Request,
R: rpc::RequestArgs,
{
let args = unwrap_ok_or!(request.to_tuple_buffer(),
Err(e) => { return cb(Err(e.into())) }
......@@ -449,7 +449,7 @@ impl ConnectionPool {
req: &R,
) -> Result<impl Future<Output = Result<R::Response>>>
where
R: rpc::Request,
R: rpc::RequestArgs,
{
let (tx, mut rx) = oneshot::channel();
id.get_or_create_in(self)?.rpc(req, move |res| {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment