#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClusterConfChangeRequest {
#[prost(uint32, tag = "1")]
pub id: u32,
#[prost(uint64, tag = "2")]
pub term: u64,
#[prost(uint64, tag = "3")]
pub version: u64,
#[prost(message, optional, tag = "4")]
pub change: ::core::option::Option<super::super::common::MembershipChange>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ClusterConfUpdateResponse {
#[prost(uint32, tag = "1")]
pub id: u32,
#[prost(uint64, tag = "2")]
pub term: u64,
#[prost(uint64, tag = "3")]
pub version: u64,
#[prost(bool, tag = "4")]
pub success: bool,
#[prost(enumeration = "cluster_conf_update_response::ErrorCode", tag = "5")]
pub error_code: i32,
}
pub mod cluster_conf_update_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ErrorCode {
Unspecified = 0,
NotLeader = 1,
VersionConflict = 2,
TermOutdated = 3,
InvalidChange = 4,
InternalError = 5,
}
impl ErrorCode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ERROR_CODE_UNSPECIFIED",
Self::NotLeader => "ERROR_CODE_NOT_LEADER",
Self::VersionConflict => "ERROR_CODE_VERSION_CONFLICT",
Self::TermOutdated => "ERROR_CODE_TERM_OUTDATED",
Self::InvalidChange => "ERROR_CODE_INVALID_CHANGE",
Self::InternalError => "ERROR_CODE_INTERNAL_ERROR",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ERROR_CODE_UNSPECIFIED" => Some(Self::Unspecified),
"ERROR_CODE_NOT_LEADER" => Some(Self::NotLeader),
"ERROR_CODE_VERSION_CONFLICT" => Some(Self::VersionConflict),
"ERROR_CODE_TERM_OUTDATED" => Some(Self::TermOutdated),
"ERROR_CODE_INVALID_CHANGE" => Some(Self::InvalidChange),
"ERROR_CODE_INTERNAL_ERROR" => Some(Self::InternalError),
_ => None,
}
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MetadataRequest {}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClusterMembership {
#[prost(uint64, tag = "1")]
pub version: u64,
#[prost(message, repeated, tag = "2")]
pub nodes: ::prost::alloc::vec::Vec<NodeMeta>,
#[prost(uint32, optional, tag = "3")]
pub current_leader_id: ::core::option::Option<u32>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NodeMeta {
#[prost(uint32, tag = "1")]
pub id: u32,
#[prost(string, tag = "2")]
pub address: ::prost::alloc::string::String,
#[prost(int32, tag = "3")]
pub role: i32,
#[prost(enumeration = "super::super::common::NodeStatus", tag = "4")]
pub status: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct JoinRequest {
#[prost(uint32, tag = "1")]
pub node_id: u32,
#[prost(int32, tag = "2")]
pub node_role: i32,
#[prost(string, tag = "3")]
pub address: ::prost::alloc::string::String,
#[prost(enumeration = "super::super::common::NodeStatus", tag = "4")]
pub status: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct JoinResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(string, tag = "2")]
pub error: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub config: ::core::option::Option<ClusterMembership>,
#[prost(uint64, tag = "4")]
pub config_version: u64,
#[prost(message, optional, tag = "5")]
pub snapshot_metadata: ::core::option::Option<super::storage::SnapshotMetadata>,
#[prost(uint32, tag = "6")]
pub leader_id: u32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaderDiscoveryRequest {
#[prost(uint32, tag = "1")]
pub node_id: u32,
#[prost(string, tag = "2")]
pub requester_address: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaderDiscoveryResponse {
#[prost(uint32, tag = "1")]
pub leader_id: u32,
#[prost(string, tag = "2")]
pub leader_address: ::prost::alloc::string::String,
#[prost(uint64, tag = "3")]
pub term: u64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ConfigState {
Stable = 0,
ConfigTransition = 1,
ElectionInProgress = 2,
}
impl ConfigState {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Stable => "STABLE",
Self::ConfigTransition => "CONFIG_TRANSITION",
Self::ElectionInProgress => "ELECTION_IN_PROGRESS",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STABLE" => Some(Self::Stable),
"CONFIG_TRANSITION" => Some(Self::ConfigTransition),
"ELECTION_IN_PROGRESS" => Some(Self::ElectionInProgress),
_ => None,
}
}
}
pub mod cluster_management_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ClusterManagementServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ClusterManagementServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ClusterManagementServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ClusterManagementServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ClusterManagementServiceClient::new(
InterceptedService::new(inner, interceptor),
)
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn update_cluster_conf(
&mut self,
request: impl tonic::IntoRequest<super::ClusterConfChangeRequest>,
) -> std::result::Result<
tonic::Response<super::ClusterConfUpdateResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/d_engine.server.cluster.ClusterManagementService/UpdateClusterConf",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"d_engine.server.cluster.ClusterManagementService",
"UpdateClusterConf",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn get_cluster_metadata(
&mut self,
request: impl tonic::IntoRequest<super::MetadataRequest>,
) -> std::result::Result<
tonic::Response<super::ClusterMembership>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/d_engine.server.cluster.ClusterManagementService/GetClusterMetadata",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"d_engine.server.cluster.ClusterManagementService",
"GetClusterMetadata",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn join_cluster(
&mut self,
request: impl tonic::IntoRequest<super::JoinRequest>,
) -> std::result::Result<tonic::Response<super::JoinResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/d_engine.server.cluster.ClusterManagementService/JoinCluster",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"d_engine.server.cluster.ClusterManagementService",
"JoinCluster",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn discover_leader(
&mut self,
request: impl tonic::IntoRequest<super::LeaderDiscoveryRequest>,
) -> std::result::Result<
tonic::Response<super::LeaderDiscoveryResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/d_engine.server.cluster.ClusterManagementService/DiscoverLeader",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"d_engine.server.cluster.ClusterManagementService",
"DiscoverLeader",
),
);
self.inner.unary(req, path, codec).await
}
}
}
pub mod cluster_management_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait ClusterManagementService: std::marker::Send + std::marker::Sync + 'static {
async fn update_cluster_conf(
&self,
request: tonic::Request<super::ClusterConfChangeRequest>,
) -> std::result::Result<
tonic::Response<super::ClusterConfUpdateResponse>,
tonic::Status,
>;
async fn get_cluster_metadata(
&self,
request: tonic::Request<super::MetadataRequest>,
) -> std::result::Result<
tonic::Response<super::ClusterMembership>,
tonic::Status,
>;
async fn join_cluster(
&self,
request: tonic::Request<super::JoinRequest>,
) -> std::result::Result<tonic::Response<super::JoinResponse>, tonic::Status>;
async fn discover_leader(
&self,
request: tonic::Request<super::LeaderDiscoveryRequest>,
) -> std::result::Result<
tonic::Response<super::LeaderDiscoveryResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct ClusterManagementServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> ClusterManagementServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>>
for ClusterManagementServiceServer<T>
where
T: ClusterManagementService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/d_engine.server.cluster.ClusterManagementService/UpdateClusterConf" => {
#[allow(non_camel_case_types)]
struct UpdateClusterConfSvc<T: ClusterManagementService>(pub Arc<T>);
impl<
T: ClusterManagementService,
> tonic::server::UnaryService<super::ClusterConfChangeRequest>
for UpdateClusterConfSvc<T> {
type Response = super::ClusterConfUpdateResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ClusterConfChangeRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ClusterManagementService>::update_cluster_conf(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = UpdateClusterConfSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/d_engine.server.cluster.ClusterManagementService/GetClusterMetadata" => {
#[allow(non_camel_case_types)]
struct GetClusterMetadataSvc<T: ClusterManagementService>(
pub Arc<T>,
);
impl<
T: ClusterManagementService,
> tonic::server::UnaryService<super::MetadataRequest>
for GetClusterMetadataSvc<T> {
type Response = super::ClusterMembership;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MetadataRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ClusterManagementService>::get_cluster_metadata(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetClusterMetadataSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/d_engine.server.cluster.ClusterManagementService/JoinCluster" => {
#[allow(non_camel_case_types)]
struct JoinClusterSvc<T: ClusterManagementService>(pub Arc<T>);
impl<
T: ClusterManagementService,
> tonic::server::UnaryService<super::JoinRequest>
for JoinClusterSvc<T> {
type Response = super::JoinResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::JoinRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ClusterManagementService>::join_cluster(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = JoinClusterSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/d_engine.server.cluster.ClusterManagementService/DiscoverLeader" => {
#[allow(non_camel_case_types)]
struct DiscoverLeaderSvc<T: ClusterManagementService>(pub Arc<T>);
impl<
T: ClusterManagementService,
> tonic::server::UnaryService<super::LeaderDiscoveryRequest>
for DiscoverLeaderSvc<T> {
type Response = super::LeaderDiscoveryResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::LeaderDiscoveryRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ClusterManagementService>::discover_leader(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = DiscoverLeaderSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(empty_body());
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for ClusterManagementServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "d_engine.server.cluster.ClusterManagementService";
impl<T> tonic::server::NamedService for ClusterManagementServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}