#![recursion_limit = "100000000"]
#![allow(bare_trait_objects)]
#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, clippy::all)]
pub use self::errors::*;
pub use self::types::*;
pub mod types;
#[doc(hidden)]
pub mod dependencies {
pub use common as common;
}
pub mod services {
pub mod raftex_service {
#[derive(Clone, Debug)]
pub enum AskForVoteExn {
#[doc(hidden)]
Success(crate::types::AskForVoteResponse),
ApplicationException(::fbthrift::ApplicationException),
}
impl ::std::convert::From<crate::errors::raftex_service::AskForVoteError> for AskForVoteExn {
fn from(err: crate::errors::raftex_service::AskForVoteError) -> Self {
match err {
crate::errors::raftex_service::AskForVoteError::ApplicationException(aexn) => AskForVoteExn::ApplicationException(aexn),
crate::errors::raftex_service::AskForVoteError::ThriftError(err) => AskForVoteExn::ApplicationException(::fbthrift::ApplicationException {
message: err.to_string(),
type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
}),
}
}
}
impl ::std::convert::From<::fbthrift::ApplicationException> for AskForVoteExn {
fn from(exn: ::fbthrift::ApplicationException) -> Self {
Self::ApplicationException(exn)
}
}
impl ::fbthrift::ExceptionInfo for AskForVoteExn {
fn exn_name(&self) -> &'static str {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
Self::ApplicationException(aexn) => aexn.exn_name(),
}
}
fn exn_value(&self) -> String {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
Self::ApplicationException(aexn) => aexn.exn_value(),
}
}
fn exn_is_declared(&self) -> bool {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
Self::ApplicationException(aexn) => aexn.exn_is_declared(),
}
}
}
impl ::fbthrift::ResultInfo for AskForVoteExn {
fn result_type(&self) -> ::fbthrift::ResultType {
match self {
Self::Success(_) => ::fbthrift::ResultType::Return,
Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
}
}
}
impl ::fbthrift::GetTType for AskForVoteExn {
const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}
impl<P> ::fbthrift::Serialize<P> for AskForVoteExn
where
P: ::fbthrift::ProtocolWriter,
{
fn write(&self, p: &mut P) {
if let Self::ApplicationException(aexn) = self {
return aexn.write(p);
}
p.write_struct_begin("AskForVote");
match self {
Self::Success(inner) => {
p.write_field_begin(
"Success",
::fbthrift::TType::Struct,
0i16,
);
inner.write(p);
p.write_field_end();
}
Self::ApplicationException(_aexn) => unreachable!(),
}
p.write_field_stop();
p.write_struct_end();
}
}
impl<P> ::fbthrift::Deserialize<P> for AskForVoteExn
where
P: ::fbthrift::ProtocolReader,
{
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static RETURNS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
];
let _ = p.read_struct_begin(|_| ())?;
let mut once = false;
let mut alt = ::std::option::Option::None;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
match ((fty, fid as ::std::primitive::i32), once) {
((::fbthrift::TType::Stop, _), _) => {
p.read_field_end()?;
break;
}
((::fbthrift::TType::Struct, 0i32), false) => {
once = true;
alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
}
((ty, _id), false) => p.skip(ty)?,
((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
format!(
"unwanted extra union {} field ty {:?} id {}",
"AskForVoteExn",
badty,
badid,
),
)
)),
}
p.read_field_end()?;
}
p.read_struct_end()?;
alt.ok_or_else(||
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::MissingResult,
format!("Empty union {}", "AskForVoteExn"),
)
.into(),
)
}
}
#[derive(Clone, Debug)]
pub enum AppendLogExn {
#[doc(hidden)]
Success(crate::types::AppendLogResponse),
ApplicationException(::fbthrift::ApplicationException),
}
impl ::std::convert::From<crate::errors::raftex_service::AppendLogError> for AppendLogExn {
fn from(err: crate::errors::raftex_service::AppendLogError) -> Self {
match err {
crate::errors::raftex_service::AppendLogError::ApplicationException(aexn) => AppendLogExn::ApplicationException(aexn),
crate::errors::raftex_service::AppendLogError::ThriftError(err) => AppendLogExn::ApplicationException(::fbthrift::ApplicationException {
message: err.to_string(),
type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
}),
}
}
}
impl ::std::convert::From<::fbthrift::ApplicationException> for AppendLogExn {
fn from(exn: ::fbthrift::ApplicationException) -> Self {
Self::ApplicationException(exn)
}
}
impl ::fbthrift::ExceptionInfo for AppendLogExn {
fn exn_name(&self) -> &'static str {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
Self::ApplicationException(aexn) => aexn.exn_name(),
}
}
fn exn_value(&self) -> String {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
Self::ApplicationException(aexn) => aexn.exn_value(),
}
}
fn exn_is_declared(&self) -> bool {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
Self::ApplicationException(aexn) => aexn.exn_is_declared(),
}
}
}
impl ::fbthrift::ResultInfo for AppendLogExn {
fn result_type(&self) -> ::fbthrift::ResultType {
match self {
Self::Success(_) => ::fbthrift::ResultType::Return,
Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
}
}
}
impl ::fbthrift::GetTType for AppendLogExn {
const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}
impl<P> ::fbthrift::Serialize<P> for AppendLogExn
where
P: ::fbthrift::ProtocolWriter,
{
fn write(&self, p: &mut P) {
if let Self::ApplicationException(aexn) = self {
return aexn.write(p);
}
p.write_struct_begin("AppendLog");
match self {
Self::Success(inner) => {
p.write_field_begin(
"Success",
::fbthrift::TType::Struct,
0i16,
);
inner.write(p);
p.write_field_end();
}
Self::ApplicationException(_aexn) => unreachable!(),
}
p.write_field_stop();
p.write_struct_end();
}
}
impl<P> ::fbthrift::Deserialize<P> for AppendLogExn
where
P: ::fbthrift::ProtocolReader,
{
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static RETURNS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
];
let _ = p.read_struct_begin(|_| ())?;
let mut once = false;
let mut alt = ::std::option::Option::None;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
match ((fty, fid as ::std::primitive::i32), once) {
((::fbthrift::TType::Stop, _), _) => {
p.read_field_end()?;
break;
}
((::fbthrift::TType::Struct, 0i32), false) => {
once = true;
alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
}
((ty, _id), false) => p.skip(ty)?,
((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
format!(
"unwanted extra union {} field ty {:?} id {}",
"AppendLogExn",
badty,
badid,
),
)
)),
}
p.read_field_end()?;
}
p.read_struct_end()?;
alt.ok_or_else(||
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::MissingResult,
format!("Empty union {}", "AppendLogExn"),
)
.into(),
)
}
}
#[derive(Clone, Debug)]
pub enum SendSnapshotExn {
#[doc(hidden)]
Success(crate::types::SendSnapshotResponse),
ApplicationException(::fbthrift::ApplicationException),
}
impl ::std::convert::From<crate::errors::raftex_service::SendSnapshotError> for SendSnapshotExn {
fn from(err: crate::errors::raftex_service::SendSnapshotError) -> Self {
match err {
crate::errors::raftex_service::SendSnapshotError::ApplicationException(aexn) => SendSnapshotExn::ApplicationException(aexn),
crate::errors::raftex_service::SendSnapshotError::ThriftError(err) => SendSnapshotExn::ApplicationException(::fbthrift::ApplicationException {
message: err.to_string(),
type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
}),
}
}
}
impl ::std::convert::From<::fbthrift::ApplicationException> for SendSnapshotExn {
fn from(exn: ::fbthrift::ApplicationException) -> Self {
Self::ApplicationException(exn)
}
}
impl ::fbthrift::ExceptionInfo for SendSnapshotExn {
fn exn_name(&self) -> &'static str {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
Self::ApplicationException(aexn) => aexn.exn_name(),
}
}
fn exn_value(&self) -> String {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
Self::ApplicationException(aexn) => aexn.exn_value(),
}
}
fn exn_is_declared(&self) -> bool {
match self {
Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
Self::ApplicationException(aexn) => aexn.exn_is_declared(),
}
}
}
impl ::fbthrift::ResultInfo for SendSnapshotExn {
fn result_type(&self) -> ::fbthrift::ResultType {
match self {
Self::Success(_) => ::fbthrift::ResultType::Return,
Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
}
}
}
impl ::fbthrift::GetTType for SendSnapshotExn {
const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
}
impl<P> ::fbthrift::Serialize<P> for SendSnapshotExn
where
P: ::fbthrift::ProtocolWriter,
{
fn write(&self, p: &mut P) {
if let Self::ApplicationException(aexn) = self {
return aexn.write(p);
}
p.write_struct_begin("SendSnapshot");
match self {
Self::Success(inner) => {
p.write_field_begin(
"Success",
::fbthrift::TType::Struct,
0i16,
);
inner.write(p);
p.write_field_end();
}
Self::ApplicationException(_aexn) => unreachable!(),
}
p.write_field_stop();
p.write_struct_end();
}
}
impl<P> ::fbthrift::Deserialize<P> for SendSnapshotExn
where
P: ::fbthrift::ProtocolReader,
{
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static RETURNS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
];
let _ = p.read_struct_begin(|_| ())?;
let mut once = false;
let mut alt = ::std::option::Option::None;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
match ((fty, fid as ::std::primitive::i32), once) {
((::fbthrift::TType::Stop, _), _) => {
p.read_field_end()?;
break;
}
((::fbthrift::TType::Struct, 0i32), false) => {
once = true;
alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
}
((ty, _id), false) => p.skip(ty)?,
((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
format!(
"unwanted extra union {} field ty {:?} id {}",
"SendSnapshotExn",
badty,
badid,
),
)
)),
}
p.read_field_end()?;
}
p.read_struct_end()?;
alt.ok_or_else(||
::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::MissingResult,
format!("Empty union {}", "SendSnapshotExn"),
)
.into(),
)
}
}
}
}
pub mod client {
pub struct RaftexServiceImpl<P, T, S = ::fbthrift::NoopSpawner> {
transport: T,
_phantom: ::std::marker::PhantomData<fn() -> (P, S)>,
}
impl<P, T, S> RaftexServiceImpl<P, T, S>
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
pub fn new(
transport: T,
) -> Self {
Self {
transport,
_phantom: ::std::marker::PhantomData,
}
}
pub fn transport(&self) -> &T {
&self.transport
}
fn _askForVote_impl(
&self,
arg_req: &crate::types::AskForVoteRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
use ::const_cstr::const_cstr;
use ::tracing::Instrument as _;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.askForVote";
}
let args = self::Args_RaftexService_askForVote {
req: arg_req,
_phantom: ::std::marker::PhantomData,
};
let transport = self.transport();
let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("askForVote", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call = transport
.call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call", function = "RaftexService.askForVote"));
async move {
let reply_env = call.await?;
let de = P::deserializer(reply_env);
let (res, _de): (::std::result::Result<crate::services::raftex_service::AskForVoteExn, _>, _) =
::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
let res = match res {
::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
::std::result::Result::Err(aexn) =>
::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(aexn))
};
res
}
.instrument(::tracing::info_span!("RaftexService.askForVote"))
.boxed()
}
fn _appendLog_impl(
&self,
arg_req: &crate::types::AppendLogRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
use ::const_cstr::const_cstr;
use ::tracing::Instrument as _;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.appendLog";
}
let args = self::Args_RaftexService_appendLog {
req: arg_req,
_phantom: ::std::marker::PhantomData,
};
let transport = self.transport();
let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("appendLog", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call = transport
.call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call", function = "RaftexService.appendLog"));
async move {
let reply_env = call.await?;
let de = P::deserializer(reply_env);
let (res, _de): (::std::result::Result<crate::services::raftex_service::AppendLogExn, _>, _) =
::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
let res = match res {
::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
::std::result::Result::Err(aexn) =>
::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(aexn))
};
res
}
.instrument(::tracing::info_span!("RaftexService.appendLog"))
.boxed()
}
fn _sendSnapshot_impl(
&self,
arg_req: &crate::types::SendSnapshotRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
use ::const_cstr::const_cstr;
use ::tracing::Instrument as _;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.sendSnapshot";
}
let args = self::Args_RaftexService_sendSnapshot {
req: arg_req,
_phantom: ::std::marker::PhantomData,
};
let transport = self.transport();
let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("sendSnapshot", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call = transport
.call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call", function = "RaftexService.sendSnapshot"));
async move {
let reply_env = call.await?;
let de = P::deserializer(reply_env);
let (res, _de): (::std::result::Result<crate::services::raftex_service::SendSnapshotExn, _>, _) =
::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
let res = match res {
::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
::std::result::Result::Err(aexn) =>
::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(aexn))
};
res
}
.instrument(::tracing::info_span!("RaftexService.sendSnapshot"))
.boxed()
}
}
pub trait RaftexService: ::std::marker::Send {
fn askForVote(
&self,
arg_req: &crate::types::AskForVoteRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
fn appendLog(
&self,
arg_req: &crate::types::AppendLogRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
fn sendSnapshot(
&self,
arg_req: &crate::types::SendSnapshotRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
}
pub trait RaftexServiceExt<T>: RaftexService
where
T: ::fbthrift::Transport,
{
fn askForVote_with_rpc_opts(
&self,
arg_req: &crate::types::AskForVoteRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
fn appendLog_with_rpc_opts(
&self,
arg_req: &crate::types::AppendLogRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
fn sendSnapshot_with_rpc_opts(
&self,
arg_req: &crate::types::SendSnapshotRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
}
struct Args_RaftexService_askForVote<'a> {
req: &'a crate::types::AskForVoteRequest,
_phantom: ::std::marker::PhantomData<&'a ()>,
}
impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_askForVote<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.askForVote"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
::fbthrift::Serialize::write(&self.req, p);
p.write_field_end();
p.write_field_stop();
p.write_struct_end();
}
}
struct Args_RaftexService_appendLog<'a> {
req: &'a crate::types::AppendLogRequest,
_phantom: ::std::marker::PhantomData<&'a ()>,
}
impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_appendLog<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.appendLog"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
::fbthrift::Serialize::write(&self.req, p);
p.write_field_end();
p.write_field_stop();
p.write_struct_end();
}
}
struct Args_RaftexService_sendSnapshot<'a> {
req: &'a crate::types::SendSnapshotRequest,
_phantom: ::std::marker::PhantomData<&'a ()>,
}
impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_sendSnapshot<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.sendSnapshot"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
::fbthrift::Serialize::write(&self.req, p);
p.write_field_end();
p.write_field_stop();
p.write_struct_end();
}
}
impl<P, T, S> RaftexService for RaftexServiceImpl<P, T, S>
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
fn askForVote(
&self,
arg_req: &crate::types::AskForVoteRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
let rpc_options = T::RpcOptions::default();
self._askForVote_impl(
arg_req,
rpc_options,
)
}
fn appendLog(
&self,
arg_req: &crate::types::AppendLogRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
let rpc_options = T::RpcOptions::default();
self._appendLog_impl(
arg_req,
rpc_options,
)
}
fn sendSnapshot(
&self,
arg_req: &crate::types::SendSnapshotRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
let rpc_options = T::RpcOptions::default();
self._sendSnapshot_impl(
arg_req,
rpc_options,
)
}
}
impl<P, T, S> RaftexServiceExt<T> for RaftexServiceImpl<P, T, S>
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
fn askForVote_with_rpc_opts(
&self,
arg_req: &crate::types::AskForVoteRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
self._askForVote_impl(
arg_req,
rpc_options,
)
}
fn appendLog_with_rpc_opts(
&self,
arg_req: &crate::types::AppendLogRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
self._appendLog_impl(
arg_req,
rpc_options,
)
}
fn sendSnapshot_with_rpc_opts(
&self,
arg_req: &crate::types::SendSnapshotRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
self._sendSnapshot_impl(
arg_req,
rpc_options,
)
}
}
impl<'a, S> RaftexService for S
where
S: ::std::convert::AsRef<dyn RaftexService + 'a>,
S: ::std::marker::Send,
{
fn askForVote(
&self,
arg_req: &crate::types::AskForVoteRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
self.as_ref().askForVote(
arg_req,
)
}
fn appendLog(
&self,
arg_req: &crate::types::AppendLogRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
self.as_ref().appendLog(
arg_req,
)
}
fn sendSnapshot(
&self,
arg_req: &crate::types::SendSnapshotRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
self.as_ref().sendSnapshot(
arg_req,
)
}
}
impl<'a, S, T> RaftexServiceExt<T> for S
where
S: ::std::convert::AsRef<dyn RaftexService + 'a>,
S: ::std::convert::AsRef<dyn RaftexServiceExt<T> + 'a>,
S: ::std::marker::Send,
T: ::fbthrift::Transport,
{
fn askForVote_with_rpc_opts(
&self,
arg_req: &crate::types::AskForVoteRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
<Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).askForVote_with_rpc_opts(
arg_req,
rpc_options,
)
}
fn appendLog_with_rpc_opts(
&self,
arg_req: &crate::types::AppendLogRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
<Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).appendLog_with_rpc_opts(
arg_req,
rpc_options,
)
}
fn sendSnapshot_with_rpc_opts(
&self,
arg_req: &crate::types::SendSnapshotRequest,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
<Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).sendSnapshot_with_rpc_opts(
arg_req,
rpc_options,
)
}
}
#[derive(Clone)]
pub struct make_RaftexService;
impl dyn RaftexService {
pub fn new<P, T>(
protocol: P,
transport: T,
) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
where
P: ::fbthrift::Protocol<Frame = T>,
T: ::fbthrift::Transport,
P::Deserializer: ::std::marker::Send,
{
let spawner = ::fbthrift::help::NoopSpawner;
Self::with_spawner(protocol, transport, spawner)
}
pub fn with_spawner<P, T, S>(
protocol: P,
transport: T,
spawner: S,
) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
where
P: ::fbthrift::Protocol<Frame = T>,
T: ::fbthrift::Transport,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
let _ = protocol;
let _ = spawner;
::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
}
}
impl<T> dyn RaftexServiceExt<T>
where
T: ::fbthrift::Transport,
{
pub fn new<P>(
protocol: P,
transport: T,
) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
where
P: ::fbthrift::Protocol<Frame = T>,
P::Deserializer: ::std::marker::Send,
{
let spawner = ::fbthrift::help::NoopSpawner;
Self::with_spawner(protocol, transport, spawner)
}
pub fn with_spawner<P, S>(
protocol: P,
transport: T,
spawner: S,
) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
where
P: ::fbthrift::Protocol<Frame = T>,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
let _ = protocol;
let _ = spawner;
::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
}
}
pub type RaftexServiceDynClient = <make_RaftexService as ::fbthrift::ClientFactory>::Api;
pub type RaftexServiceClient = ::std::sync::Arc<RaftexServiceDynClient>;
impl ::fbthrift::ClientFactory for make_RaftexService {
type Api = dyn RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static;
fn with_spawner<P, T, S>(protocol: P, transport: T, spawner: S) -> ::std::sync::Arc<Self::Api>
where
P: ::fbthrift::Protocol<Frame = T>,
T: ::fbthrift::Transport,
P::Deserializer: ::std::marker::Send,
S: ::fbthrift::help::Spawner,
{
<dyn RaftexService>::with_spawner(protocol, transport, spawner)
}
}
}
pub mod server {
#[::async_trait::async_trait]
pub trait RaftexService: ::std::marker::Send + ::std::marker::Sync + 'static {
async fn askForVote(
&self,
_req: crate::types::AskForVoteRequest,
) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(
::fbthrift::ApplicationException::unimplemented_method(
"RaftexService",
"askForVote",
),
))
}
async fn appendLog(
&self,
_req: crate::types::AppendLogRequest,
) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(
::fbthrift::ApplicationException::unimplemented_method(
"RaftexService",
"appendLog",
),
))
}
async fn sendSnapshot(
&self,
_req: crate::types::SendSnapshotRequest,
) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(
::fbthrift::ApplicationException::unimplemented_method(
"RaftexService",
"sendSnapshot",
),
))
}
}
#[::async_trait::async_trait]
impl<T> RaftexService for ::std::boxed::Box<T>
where
T: RaftexService + Send + Sync + ?Sized,
{
async fn askForVote(
&self,
req: crate::types::AskForVoteRequest,
) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
(**self).askForVote(
req,
).await
}
async fn appendLog(
&self,
req: crate::types::AppendLogRequest,
) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
(**self).appendLog(
req,
).await
}
async fn sendSnapshot(
&self,
req: crate::types::SendSnapshotRequest,
) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
(**self).sendSnapshot(
req,
).await
}
}
#[derive(Clone, Debug)]
pub struct RaftexServiceProcessor<P, H, R, RS> {
service: H,
supa: ::fbthrift::NullServiceProcessor<P, R, RS>,
_phantom: ::std::marker::PhantomData<(P, H, R, RS)>,
}
struct Args_RaftexService_askForVote {
req: crate::types::AskForVoteRequest,
}
impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_askForVote {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.askForVote"))]
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static ARGS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
];
let mut field_req = ::std::option::Option::None;
let _ = p.read_struct_begin(|_| ())?;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
match (fty, fid as ::std::primitive::i32) {
(::fbthrift::TType::Stop, _) => break,
(::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
(fty, _) => p.skip(fty)?,
}
p.read_field_end()?;
}
p.read_struct_end()?;
::std::result::Result::Ok(Self {
req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.askForVote", "req"))?,
})
}
}
struct Args_RaftexService_appendLog {
req: crate::types::AppendLogRequest,
}
impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_appendLog {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.appendLog"))]
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static ARGS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
];
let mut field_req = ::std::option::Option::None;
let _ = p.read_struct_begin(|_| ())?;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
match (fty, fid as ::std::primitive::i32) {
(::fbthrift::TType::Stop, _) => break,
(::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
(fty, _) => p.skip(fty)?,
}
p.read_field_end()?;
}
p.read_struct_end()?;
::std::result::Result::Ok(Self {
req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.appendLog", "req"))?,
})
}
}
struct Args_RaftexService_sendSnapshot {
req: crate::types::SendSnapshotRequest,
}
impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_sendSnapshot {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.sendSnapshot"))]
fn read(p: &mut P) -> ::anyhow::Result<Self> {
static ARGS: &[::fbthrift::Field] = &[
::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
];
let mut field_req = ::std::option::Option::None;
let _ = p.read_struct_begin(|_| ())?;
loop {
let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
match (fty, fid as ::std::primitive::i32) {
(::fbthrift::TType::Stop, _) => break,
(::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
(fty, _) => p.skip(fty)?,
}
p.read_field_end()?;
}
p.read_struct_end()?;
::std::result::Result::Ok(Self {
req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.sendSnapshot", "req"))?,
})
}
}
impl<P, H, R, RS> RaftexServiceProcessor<P, H, R, RS>
where
P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
P::Frame: ::std::marker::Send + 'static,
P::Deserializer: ::std::marker::Send,
H: RaftexService,
R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static,
<R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
+ ::std::marker::Send + ::std::marker::Sync,
{
pub fn new(service: H) -> Self {
Self {
service,
supa: ::fbthrift::NullServiceProcessor::new(),
_phantom: ::std::marker::PhantomData,
}
}
pub fn into_inner(self) -> H {
self.service
}
#[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.askForVote"))]
async fn handle_askForVote<'a>(
&'a self,
p: &'a mut P::Deserializer,
req_ctxt: &R,
reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
_seqid: ::std::primitive::u32,
) -> ::anyhow::Result<()> {
use ::const_cstr::const_cstr;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.askForVote";
}
let mut ctx_stack = req_ctxt.get_context_stack(
SERVICE_NAME.as_cstr(),
METHOD_NAME.as_cstr(),
)?;
::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
let _args: self::Args_RaftexService_askForVote = ::fbthrift::Deserialize::read(p)?;
::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
protocol: P::PROTOCOL_ID,
method_name: METHOD_NAME.as_cstr(),
buffer: ::std::marker::PhantomData, })?;
::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
let res = ::std::panic::AssertUnwindSafe(
self.service.askForVote(
_args.req,
)
)
.catch_unwind()
.await;
let res = match res {
::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
::tracing::info!("success");
crate::services::raftex_service::AskForVoteExn::Success(res)
}
::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::Success(_))) => {
panic!(
"{} attempted to return success via error",
"askForVote",
)
}
::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
::tracing::error!(exception = ?exn);
exn
}
::std::result::Result::Err(exn) => {
let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.askForVote", exn);
crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn)
}
};
let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
"askForVote",
METHOD_NAME.as_cstr(),
_seqid,
req_ctxt,
&mut ctx_stack,
res
)?;
reply_state.lock().unwrap().send_reply(env);
Ok(())
}
#[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.appendLog"))]
async fn handle_appendLog<'a>(
&'a self,
p: &'a mut P::Deserializer,
req_ctxt: &R,
reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
_seqid: ::std::primitive::u32,
) -> ::anyhow::Result<()> {
use ::const_cstr::const_cstr;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.appendLog";
}
let mut ctx_stack = req_ctxt.get_context_stack(
SERVICE_NAME.as_cstr(),
METHOD_NAME.as_cstr(),
)?;
::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
let _args: self::Args_RaftexService_appendLog = ::fbthrift::Deserialize::read(p)?;
::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
protocol: P::PROTOCOL_ID,
method_name: METHOD_NAME.as_cstr(),
buffer: ::std::marker::PhantomData, })?;
::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
let res = ::std::panic::AssertUnwindSafe(
self.service.appendLog(
_args.req,
)
)
.catch_unwind()
.await;
let res = match res {
::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
::tracing::info!("success");
crate::services::raftex_service::AppendLogExn::Success(res)
}
::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::Success(_))) => {
panic!(
"{} attempted to return success via error",
"appendLog",
)
}
::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
::tracing::error!(exception = ?exn);
exn
}
::std::result::Result::Err(exn) => {
let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.appendLog", exn);
crate::services::raftex_service::AppendLogExn::ApplicationException(aexn)
}
};
let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
"appendLog",
METHOD_NAME.as_cstr(),
_seqid,
req_ctxt,
&mut ctx_stack,
res
)?;
reply_state.lock().unwrap().send_reply(env);
Ok(())
}
#[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.sendSnapshot"))]
async fn handle_sendSnapshot<'a>(
&'a self,
p: &'a mut P::Deserializer,
req_ctxt: &R,
reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
_seqid: ::std::primitive::u32,
) -> ::anyhow::Result<()> {
use ::const_cstr::const_cstr;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "RaftexService";
METHOD_NAME = "RaftexService.sendSnapshot";
}
let mut ctx_stack = req_ctxt.get_context_stack(
SERVICE_NAME.as_cstr(),
METHOD_NAME.as_cstr(),
)?;
::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
let _args: self::Args_RaftexService_sendSnapshot = ::fbthrift::Deserialize::read(p)?;
::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
protocol: P::PROTOCOL_ID,
method_name: METHOD_NAME.as_cstr(),
buffer: ::std::marker::PhantomData, })?;
::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
let res = ::std::panic::AssertUnwindSafe(
self.service.sendSnapshot(
_args.req,
)
)
.catch_unwind()
.await;
let res = match res {
::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
::tracing::info!("success");
crate::services::raftex_service::SendSnapshotExn::Success(res)
}
::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::Success(_))) => {
panic!(
"{} attempted to return success via error",
"sendSnapshot",
)
}
::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
::tracing::error!(exception = ?exn);
exn
}
::std::result::Result::Err(exn) => {
let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.sendSnapshot", exn);
crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn)
}
};
let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
"sendSnapshot",
METHOD_NAME.as_cstr(),
_seqid,
req_ctxt,
&mut ctx_stack,
res
)?;
reply_state.lock().unwrap().send_reply(env);
Ok(())
}
}
#[::async_trait::async_trait]
impl<P, H, R, RS> ::fbthrift::ServiceProcessor<P> for RaftexServiceProcessor<P, H, R, RS>
where
P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
P::Deserializer: ::std::marker::Send,
H: RaftexService,
P::Frame: ::std::marker::Send + 'static,
R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
<R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
+ ::std::marker::Send + ::std::marker::Sync + 'static,
RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
{
type RequestContext = R;
type ReplyState = RS;
#[inline]
fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> {
match name {
b"askForVote" => ::std::result::Result::Ok(0usize),
b"appendLog" => ::std::result::Result::Ok(1usize),
b"sendSnapshot" => ::std::result::Result::Ok(2usize),
_ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()),
}
}
#[allow(clippy::match_single_binding)]
async fn handle_method(
&self,
idx: ::std::primitive::usize,
_p: &mut P::Deserializer,
_r: &R,
_reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
_seqid: ::std::primitive::u32,
) -> ::anyhow::Result<()> {
match idx {
0usize => {
self.handle_askForVote(_p, _r, _reply_state, _seqid).await
}
1usize => {
self.handle_appendLog(_p, _r, _reply_state, _seqid).await
}
2usize => {
self.handle_sendSnapshot(_p, _r, _reply_state, _seqid).await
}
bad => panic!(
"{}: unexpected method idx {}",
"RaftexServiceProcessor",
bad
),
}
}
#[allow(clippy::match_single_binding)]
#[inline]
fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> {
match name {
_ => ::anyhow::bail!("Unknown interaction"),
}
}
#[allow(clippy::match_single_binding)]
fn handle_create_interaction(
&self,
idx: ::std::primitive::usize,
) -> ::anyhow::Result<
::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = Self::RequestContext, ReplyState = Self::ReplyState> + ::std::marker::Send + 'static>
> {
match idx {
bad => panic!(
"{}: unexpected method idx {}",
"RaftexServiceProcessor",
bad
),
}
}
}
#[::async_trait::async_trait]
impl<P, H, R, RS> ::fbthrift::ThriftService<P::Frame> for RaftexServiceProcessor<P, H, R, RS>
where
P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
P::Deserializer: ::std::marker::Send,
P::Frame: ::std::marker::Send + 'static,
H: RaftexService,
R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
<R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
+ ::std::marker::Send + ::std::marker::Sync + 'static,
RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
{
type Handler = H;
type RequestContext = R;
type ReplyState = RS;
#[tracing::instrument(level="trace", skip_all, fields(service = "RaftexService"))]
async fn call(
&self,
req: ::fbthrift::ProtocolDecoded<P>,
req_ctxt: &R,
reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
) -> ::anyhow::Result<()> {
use ::fbthrift::{BufExt as _, ProtocolReader as _, ServiceProcessor as _};
let mut p = P::deserializer(req);
let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?;
if mty != ::fbthrift::MessageType::Call {
return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new(
::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType,
format!("message type {:?} not handled", mty)
)));
}
let idx = match idx {
::std::result::Result::Ok(idx) => idx,
::std::result::Result::Err(_) => {
let cur = P::into_buffer(p).reset();
return self.supa.call(cur, req_ctxt, reply_state).await;
}
};
self.handle_method(idx, &mut p, req_ctxt, reply_state, seqid).await?;
p.read_message_end()?;
Ok(())
}
fn create_interaction(
&self,
name: &str,
) -> ::anyhow::Result<
::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>
> {
use ::fbthrift::{ServiceProcessor as _};
let idx = self.create_interaction_idx(name);
let idx = match idx {
::anyhow::Result::Ok(idx) => idx,
::anyhow::Result::Err(_) => {
return self.supa.create_interaction(name);
}
};
self.handle_create_interaction(idx)
}
fn get_method_names(&self) -> &'static [&'static str] {
&[
"askForVote",
"appendLog",
"sendSnapshot",
]
}
}
#[::tracing::instrument(level="debug", skip_all, fields(proto = ?proto))]
pub fn make_RaftexService_server<F, H, R, RS>(
proto: ::fbthrift::ProtocolID,
handler: H,
) -> ::std::result::Result<::std::boxed::Box<dyn ::fbthrift::ThriftService<F, Handler = H, RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException>
where
F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static,
H: RaftexService,
R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
<R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = F::DecBuf> + ::std::marker::Send + ::std::marker::Sync + 'static,
RS: ::fbthrift::ReplyState<F, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
{
match proto {
::fbthrift::ProtocolID::BinaryProtocol => {
::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::BinaryProtocol<F>, H, R, RS>::new(handler)))
}
::fbthrift::ProtocolID::CompactProtocol => {
::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::CompactProtocol<F>, H, R, RS>::new(handler)))
}
bad => {
::tracing::error!(method = "RaftexService.", invalid_protocol = ?bad);
::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad))
}
}
}
}
pub mod mock {
pub struct RaftexService<'mock> {
pub askForVote: r#impl::raftex_service::askForVote<'mock>,
pub appendLog: r#impl::raftex_service::appendLog<'mock>,
pub sendSnapshot: r#impl::raftex_service::sendSnapshot<'mock>,
_marker: ::std::marker::PhantomData<&'mock ()>,
}
impl dyn super::client::RaftexService {
pub fn mock<'mock>() -> RaftexService<'mock> {
RaftexService {
askForVote: r#impl::raftex_service::askForVote::unimplemented(),
appendLog: r#impl::raftex_service::appendLog::unimplemented(),
sendSnapshot: r#impl::raftex_service::sendSnapshot::unimplemented(),
_marker: ::std::marker::PhantomData,
}
}
}
impl<'mock> super::client::RaftexService for RaftexService<'mock> {
fn askForVote(
&self,
arg_req: &crate::types::AskForVoteRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
let mut closure = self.askForVote.closure.lock().unwrap();
let closure: &mut dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> _ = &mut **closure;
::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
}
fn appendLog(
&self,
arg_req: &crate::types::AppendLogRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
let mut closure = self.appendLog.closure.lock().unwrap();
let closure: &mut dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> _ = &mut **closure;
::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
}
fn sendSnapshot(
&self,
arg_req: &crate::types::SendSnapshotRequest,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
let mut closure = self.sendSnapshot.closure.lock().unwrap();
let closure: &mut dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> _ = &mut **closure;
::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
}
}
mod r#impl {
pub mod raftex_service {
pub struct askForVote<'mock> {
pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<
crate::types::AskForVoteResponse,
crate::errors::raftex_service::AskForVoteError,
> + ::std::marker::Send + ::std::marker::Sync + 'mock,
>>,
}
#[allow(clippy::redundant_closure)]
impl<'mock> askForVote<'mock> {
pub fn unimplemented() -> Self {
Self {
closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AskForVoteRequest| panic!(
"{}::{} is not mocked",
"RaftexService",
"askForVote",
))),
}
}
pub fn ret(&self, value: crate::types::AskForVoteResponse) {
self.mock(move |_: crate::types::AskForVoteRequest| value.clone());
}
pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> crate::types::AskForVoteResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
}
pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| mock(req));
}
pub fn throw<E>(&self, exception: E)
where
E: ::std::convert::Into<crate::errors::raftex_service::AskForVoteError>,
E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
{
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |_: crate::types::AskForVoteRequest| ::std::result::Result::Err(exception.clone().into()));
}
}
pub struct appendLog<'mock> {
pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<
crate::types::AppendLogResponse,
crate::errors::raftex_service::AppendLogError,
> + ::std::marker::Send + ::std::marker::Sync + 'mock,
>>,
}
#[allow(clippy::redundant_closure)]
impl<'mock> appendLog<'mock> {
pub fn unimplemented() -> Self {
Self {
closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AppendLogRequest| panic!(
"{}::{} is not mocked",
"RaftexService",
"appendLog",
))),
}
}
pub fn ret(&self, value: crate::types::AppendLogResponse) {
self.mock(move |_: crate::types::AppendLogRequest| value.clone());
}
pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> crate::types::AppendLogResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
}
pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| mock(req));
}
pub fn throw<E>(&self, exception: E)
where
E: ::std::convert::Into<crate::errors::raftex_service::AppendLogError>,
E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
{
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |_: crate::types::AppendLogRequest| ::std::result::Result::Err(exception.clone().into()));
}
}
pub struct sendSnapshot<'mock> {
pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<
crate::types::SendSnapshotResponse,
crate::errors::raftex_service::SendSnapshotError,
> + ::std::marker::Send + ::std::marker::Sync + 'mock,
>>,
}
#[allow(clippy::redundant_closure)]
impl<'mock> sendSnapshot<'mock> {
pub fn unimplemented() -> Self {
Self {
closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::SendSnapshotRequest| panic!(
"{}::{} is not mocked",
"RaftexService",
"sendSnapshot",
))),
}
}
pub fn ret(&self, value: crate::types::SendSnapshotResponse) {
self.mock(move |_: crate::types::SendSnapshotRequest| value.clone());
}
pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> crate::types::SendSnapshotResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
}
pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |req| mock(req));
}
pub fn throw<E>(&self, exception: E)
where
E: ::std::convert::Into<crate::errors::raftex_service::SendSnapshotError>,
E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
{
let mut closure = self.closure.lock().unwrap();
*closure = ::std::boxed::Box::new(move |_: crate::types::SendSnapshotRequest| ::std::result::Result::Err(exception.clone().into()));
}
}
}
}
}
pub mod errors {
pub mod raftex_service {
pub type AskForVoteError = ::fbthrift::NonthrowingFunctionError;
impl ::std::convert::From<crate::services::raftex_service::AskForVoteExn> for
::std::result::Result<crate::types::AskForVoteResponse, AskForVoteError>
{
fn from(e: crate::services::raftex_service::AskForVoteExn) -> Self {
match e {
crate::services::raftex_service::AskForVoteExn::Success(res) => {
::std::result::Result::Ok(res)
}
crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn) =>
::std::result::Result::Err(AskForVoteError::ApplicationException(aexn)),
}
}
}
pub type AppendLogError = ::fbthrift::NonthrowingFunctionError;
impl ::std::convert::From<crate::services::raftex_service::AppendLogExn> for
::std::result::Result<crate::types::AppendLogResponse, AppendLogError>
{
fn from(e: crate::services::raftex_service::AppendLogExn) -> Self {
match e {
crate::services::raftex_service::AppendLogExn::Success(res) => {
::std::result::Result::Ok(res)
}
crate::services::raftex_service::AppendLogExn::ApplicationException(aexn) =>
::std::result::Result::Err(AppendLogError::ApplicationException(aexn)),
}
}
}
pub type SendSnapshotError = ::fbthrift::NonthrowingFunctionError;
impl ::std::convert::From<crate::services::raftex_service::SendSnapshotExn> for
::std::result::Result<crate::types::SendSnapshotResponse, SendSnapshotError>
{
fn from(e: crate::services::raftex_service::SendSnapshotExn) -> Self {
match e {
crate::services::raftex_service::SendSnapshotExn::Success(res) => {
::std::result::Result::Ok(res)
}
crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn) =>
::std::result::Result::Err(SendSnapshotError::ApplicationException(aexn)),
}
}
}
}
}