Skip to content
Snippets Groups Projects
Commit 3990c09e authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

feat(rpc): traft::rpc::Request trait

parent 8890e1be
No related branches found
No related tags found
1 merge request!259feat(network): arbitrary sync/async rpc requests
......@@ -26,7 +26,7 @@ macro_rules! stringify_cfunc {
use ::tarantool::tuple::FunctionCtx;
use libc::c_int;
let _: unsafe extern "C" fn(FunctionCtx, FunctionArgs) -> c_int = $($func_name)+;
const _: unsafe extern "C" fn(FunctionCtx, FunctionArgs) -> c_int = $($func_name)+;
concat!(".", $crate::stringify_last_token!($($func_name)+))
}};
}
......
......@@ -7,6 +7,7 @@ mod network;
pub mod node;
pub mod notify;
mod raft_storage;
pub mod rpc;
pub mod storage;
pub mod topology;
......
use ::tarantool::tuple::{DecodeOwned, Encode};
use std::fmt::Debug;
/// Types implementing this trait represent an RPC's (remote procedure call)
/// arguments. This trait contains information about the request.
pub trait Request: Encode + DecodeOwned {
/// Remote procedure name.
const PROC_NAME: &'static str;
/// Describes data returned from a successful RPC request.
type Response: Encode + DecodeOwned + Debug + 'static;
}
impl Request for super::JoinRequest {
const PROC_NAME: &'static str = crate::stringify_cfunc!(super::node::raft_join);
type Response = super::JoinResponse;
}
impl Request for super::UpdatePeerRequest {
const PROC_NAME: &'static str = crate::stringify_cfunc!(super::failover::raft_update_peer);
type Response = super::UpdatePeerResponse;
}
impl Request for super::ExpelRequest {
const PROC_NAME: &'static str = crate::stringify_cfunc!(super::node::raft_expel);
type Response = super::ExpelResponse;
}
impl Request for super::SyncRaftRequest {
const PROC_NAME: &'static str = crate::stringify_cfunc!(super::node::raft_sync_raft);
type Response = ();
}
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