photoncloud-monorepo/chainfire/crates/chainfire-api/src/generated/chainfire.v1.rs
centra 8f94aee1fa Fix R8: Convert submodule gitlinks to regular directories
- Remove gitlinks (160000 mode) for chainfire, flaredb, iam
- Add workspace contents as regular tracked files
- Update flake.nix to use simple paths instead of builtins.fetchGit

This resolves the nix build failure where submodule directories
appeared empty in the nix store.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 16:51:20 +09:00

1817 lines
72 KiB
Rust

// This file is @generated by prost-build.
/// Response header included in all responses
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ResponseHeader {
/// cluster_id is the ID of the cluster
#[prost(uint64, tag = "1")]
pub cluster_id: u64,
/// member_id is the ID of the responding member
#[prost(uint64, tag = "2")]
pub member_id: u64,
/// revision is the key-value store revision
#[prost(int64, tag = "3")]
pub revision: i64,
/// raft_term is the current Raft term
#[prost(uint64, tag = "4")]
pub raft_term: u64,
}
/// Key-value pair
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValue {
/// key is the key in bytes
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// create_revision is the revision of last creation
#[prost(int64, tag = "2")]
pub create_revision: i64,
/// mod_revision is the revision of last modification
#[prost(int64, tag = "3")]
pub mod_revision: i64,
/// version is the version of the key
#[prost(int64, tag = "4")]
pub version: i64,
/// value is the value held by the key
#[prost(bytes = "vec", tag = "5")]
pub value: ::prost::alloc::vec::Vec<u8>,
/// lease is the ID of the lease attached to the key
#[prost(int64, tag = "6")]
pub lease: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RangeRequest {
/// key is the first key for the range
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// range_end is the upper bound on the requested range
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
/// limit is a limit on the number of keys returned
#[prost(int64, tag = "3")]
pub limit: i64,
/// revision is the point-in-time of the store to use
#[prost(int64, tag = "4")]
pub revision: i64,
/// keys_only when set returns only the keys and not the values
#[prost(bool, tag = "5")]
pub keys_only: bool,
/// count_only when set returns only the count of the keys
#[prost(bool, tag = "6")]
pub count_only: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RangeResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// kvs is the list of key-value pairs matched by the range request
#[prost(message, repeated, tag = "2")]
pub kvs: ::prost::alloc::vec::Vec<KeyValue>,
/// more indicates if there are more keys to return
#[prost(bool, tag = "3")]
pub more: bool,
/// count is set to the number of keys within the range
#[prost(int64, tag = "4")]
pub count: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutRequest {
/// key is the key to put
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// value is the value to put
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
/// lease is the lease ID to attach to the key
#[prost(int64, tag = "3")]
pub lease: i64,
/// prev_kv when set returns the previous key-value pair
#[prost(bool, tag = "4")]
pub prev_kv: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// prev_kv is the key-value pair before the put
#[prost(message, optional, tag = "2")]
pub prev_kv: ::core::option::Option<KeyValue>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeRequest {
/// key is the first key to delete
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// range_end is the key following the last key to delete
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
/// prev_kv when set returns deleted key-value pairs
#[prost(bool, tag = "3")]
pub prev_kv: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// deleted is the number of keys deleted
#[prost(int64, tag = "2")]
pub deleted: i64,
/// prev_kvs holds the deleted key-value pairs
#[prost(message, repeated, tag = "3")]
pub prev_kvs: ::prost::alloc::vec::Vec<KeyValue>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnRequest {
/// compare is a list of predicates
#[prost(message, repeated, tag = "1")]
pub compare: ::prost::alloc::vec::Vec<Compare>,
/// success is a list of operations to apply if all comparisons succeed
#[prost(message, repeated, tag = "2")]
pub success: ::prost::alloc::vec::Vec<RequestOp>,
/// failure is a list of operations to apply if any comparison fails
#[prost(message, repeated, tag = "3")]
pub failure: ::prost::alloc::vec::Vec<RequestOp>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// succeeded is set to true if all comparisons evaluated to true
#[prost(bool, tag = "2")]
pub succeeded: bool,
/// responses is a list of responses corresponding to the results
#[prost(message, repeated, tag = "3")]
pub responses: ::prost::alloc::vec::Vec<ResponseOp>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Compare {
#[prost(enumeration = "compare::CompareResult", tag = "1")]
pub result: i32,
#[prost(enumeration = "compare::CompareTarget", tag = "2")]
pub target: i32,
#[prost(bytes = "vec", tag = "3")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(oneof = "compare::TargetUnion", tags = "4, 5, 6, 7")]
pub target_union: ::core::option::Option<compare::TargetUnion>,
}
/// Nested message and enum types in `Compare`.
pub mod compare {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum CompareResult {
Equal = 0,
Greater = 1,
Less = 2,
NotEqual = 3,
}
impl CompareResult {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Equal => "EQUAL",
Self::Greater => "GREATER",
Self::Less => "LESS",
Self::NotEqual => "NOT_EQUAL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"EQUAL" => Some(Self::Equal),
"GREATER" => Some(Self::Greater),
"LESS" => Some(Self::Less),
"NOT_EQUAL" => Some(Self::NotEqual),
_ => None,
}
}
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum CompareTarget {
Version = 0,
Create = 1,
Mod = 2,
Value = 3,
}
impl CompareTarget {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Version => "VERSION",
Self::Create => "CREATE",
Self::Mod => "MOD",
Self::Value => "VALUE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"VERSION" => Some(Self::Version),
"CREATE" => Some(Self::Create),
"MOD" => Some(Self::Mod),
"VALUE" => Some(Self::Value),
_ => None,
}
}
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum TargetUnion {
#[prost(int64, tag = "4")]
Version(i64),
#[prost(int64, tag = "5")]
CreateRevision(i64),
#[prost(int64, tag = "6")]
ModRevision(i64),
#[prost(bytes, tag = "7")]
Value(::prost::alloc::vec::Vec<u8>),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestOp {
#[prost(oneof = "request_op::Request", tags = "1, 2, 3")]
pub request: ::core::option::Option<request_op::Request>,
}
/// Nested message and enum types in `RequestOp`.
pub mod request_op {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
#[prost(message, tag = "1")]
RequestRange(super::RangeRequest),
#[prost(message, tag = "2")]
RequestPut(super::PutRequest),
#[prost(message, tag = "3")]
RequestDeleteRange(super::DeleteRangeRequest),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseOp {
#[prost(oneof = "response_op::Response", tags = "1, 2, 3")]
pub response: ::core::option::Option<response_op::Response>,
}
/// Nested message and enum types in `ResponseOp`.
pub mod response_op {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
ResponseRange(super::RangeResponse),
#[prost(message, tag = "2")]
ResponsePut(super::PutResponse),
#[prost(message, tag = "3")]
ResponseDeleteRange(super::DeleteRangeResponse),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchRequest {
#[prost(oneof = "watch_request::RequestUnion", tags = "1, 2, 3")]
pub request_union: ::core::option::Option<watch_request::RequestUnion>,
}
/// Nested message and enum types in `WatchRequest`.
pub mod watch_request {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum RequestUnion {
#[prost(message, tag = "1")]
CreateRequest(super::WatchCreateRequest),
#[prost(message, tag = "2")]
CancelRequest(super::WatchCancelRequest),
#[prost(message, tag = "3")]
ProgressRequest(super::WatchProgressRequest),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchCreateRequest {
/// key is the key to watch
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
/// range_end is the end of the range to watch
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
/// start_revision is an optional revision to start watching from
#[prost(int64, tag = "3")]
pub start_revision: i64,
/// progress_notify is set to true to enable progress notifications
#[prost(bool, tag = "4")]
pub progress_notify: bool,
/// prev_kv when set includes previous key-value in events
#[prost(bool, tag = "5")]
pub prev_kv: bool,
/// watch_id is the user-provided watch ID (0 for server-assigned)
#[prost(int64, tag = "6")]
pub watch_id: i64,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct WatchCancelRequest {
/// watch_id is the watch ID to cancel
#[prost(int64, tag = "1")]
pub watch_id: i64,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct WatchProgressRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// watch_id is the watch ID for this response
#[prost(int64, tag = "2")]
pub watch_id: i64,
/// created is set to true if this response is for a create request
#[prost(bool, tag = "3")]
pub created: bool,
/// canceled is set to true if the watch was canceled
#[prost(bool, tag = "4")]
pub canceled: bool,
/// compact_revision is the minimum revision the watcher may receive
#[prost(int64, tag = "5")]
pub compact_revision: i64,
/// cancel_reason indicates the reason for cancellation
#[prost(string, tag = "6")]
pub cancel_reason: ::prost::alloc::string::String,
/// events is the list of events in this response
#[prost(message, repeated, tag = "11")]
pub events: ::prost::alloc::vec::Vec<Event>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Event {
/// type is the kind of event
#[prost(enumeration = "event::EventType", tag = "1")]
pub r#type: i32,
/// kv is the KeyValue affected by the event
#[prost(message, optional, tag = "2")]
pub kv: ::core::option::Option<KeyValue>,
/// prev_kv is the KeyValue prior to the event
#[prost(message, optional, tag = "3")]
pub prev_kv: ::core::option::Option<KeyValue>,
}
/// Nested message and enum types in `Event`.
pub mod event {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum EventType {
Put = 0,
Delete = 1,
}
impl EventType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Put => "PUT",
Self::Delete => "DELETE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"PUT" => Some(Self::Put),
"DELETE" => Some(Self::Delete),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Member {
/// ID is the member ID
#[prost(uint64, tag = "1")]
pub id: u64,
/// name is the human-readable name
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
/// peer_urls are URLs for Raft communication
#[prost(string, repeated, tag = "3")]
pub peer_urls: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// client_urls are URLs for client communication
#[prost(string, repeated, tag = "4")]
pub client_urls: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// is_learner indicates if member is a learner
#[prost(bool, tag = "5")]
pub is_learner: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MemberAddRequest {
/// peer_urls are the URLs to reach the new member
#[prost(string, repeated, tag = "1")]
pub peer_urls: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// is_learner indicates if the member is a learner
#[prost(bool, tag = "2")]
pub is_learner: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MemberAddResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// member is the member information for the added member
#[prost(message, optional, tag = "2")]
pub member: ::core::option::Option<Member>,
/// members is the list of all members after adding
#[prost(message, repeated, tag = "3")]
pub members: ::prost::alloc::vec::Vec<Member>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MemberRemoveRequest {
/// ID is the member ID to remove
#[prost(uint64, tag = "1")]
pub id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MemberRemoveResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// members is the list of all members after removing
#[prost(message, repeated, tag = "2")]
pub members: ::prost::alloc::vec::Vec<Member>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MemberListRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MemberListResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// members is the list of all members
#[prost(message, repeated, tag = "2")]
pub members: ::prost::alloc::vec::Vec<Member>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct StatusRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatusResponse {
#[prost(message, optional, tag = "1")]
pub header: ::core::option::Option<ResponseHeader>,
/// version is the version of the server
#[prost(string, tag = "2")]
pub version: ::prost::alloc::string::String,
/// db_size is the size of the database
#[prost(int64, tag = "3")]
pub db_size: i64,
/// leader is the member ID of the current leader
#[prost(uint64, tag = "4")]
pub leader: u64,
/// raft_index is the current Raft committed index
#[prost(uint64, tag = "5")]
pub raft_index: u64,
/// raft_term is the current Raft term
#[prost(uint64, tag = "6")]
pub raft_term: u64,
/// raft_applied_index is the current Raft applied index
#[prost(uint64, tag = "7")]
pub raft_applied_index: u64,
}
/// Generated client implementations.
pub mod kv_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Key-Value service
#[derive(Debug, Clone)]
pub struct KvClient<T> {
inner: tonic::client::Grpc<T>,
}
impl KvClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
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> KvClient<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,
) -> KvClient<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,
{
KvClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Range gets the keys in the range from the key-value store
pub async fn range(
&mut self,
request: impl tonic::IntoRequest<super::RangeRequest>,
) -> std::result::Result<tonic::Response<super::RangeResponse>, 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("/chainfire.v1.KV/Range");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("chainfire.v1.KV", "Range"));
self.inner.unary(req, path, codec).await
}
/// Put puts the given key into the key-value store
pub async fn put(
&mut self,
request: impl tonic::IntoRequest<super::PutRequest>,
) -> std::result::Result<tonic::Response<super::PutResponse>, 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("/chainfire.v1.KV/Put");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("chainfire.v1.KV", "Put"));
self.inner.unary(req, path, codec).await
}
/// Delete deletes the given range from the key-value store
pub async fn delete(
&mut self,
request: impl tonic::IntoRequest<super::DeleteRangeRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteRangeResponse>,
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("/chainfire.v1.KV/Delete");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("chainfire.v1.KV", "Delete"));
self.inner.unary(req, path, codec).await
}
/// Txn processes multiple requests in a single transaction
pub async fn txn(
&mut self,
request: impl tonic::IntoRequest<super::TxnRequest>,
) -> std::result::Result<tonic::Response<super::TxnResponse>, 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("/chainfire.v1.KV/Txn");
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("chainfire.v1.KV", "Txn"));
self.inner.unary(req, path, codec).await
}
}
}
/// Generated client implementations.
pub mod watch_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Watch service
#[derive(Debug, Clone)]
pub struct WatchClient<T> {
inner: tonic::client::Grpc<T>,
}
impl WatchClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
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> WatchClient<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,
) -> WatchClient<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,
{
WatchClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Watch watches for events happening or that have happened
pub async fn watch(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::WatchRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::WatchResponse>>,
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("/chainfire.v1.Watch/Watch");
let mut req = request.into_streaming_request();
req.extensions_mut().insert(GrpcMethod::new("chainfire.v1.Watch", "Watch"));
self.inner.streaming(req, path, codec).await
}
}
}
/// Generated client implementations.
pub mod cluster_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Cluster management service
#[derive(Debug, Clone)]
pub struct ClusterClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ClusterClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
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> ClusterClient<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,
) -> ClusterClient<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,
{
ClusterClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// MemberAdd adds a member into the cluster
pub async fn member_add(
&mut self,
request: impl tonic::IntoRequest<super::MemberAddRequest>,
) -> std::result::Result<
tonic::Response<super::MemberAddResponse>,
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(
"/chainfire.v1.Cluster/MemberAdd",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("chainfire.v1.Cluster", "MemberAdd"));
self.inner.unary(req, path, codec).await
}
/// MemberRemove removes an existing member from the cluster
pub async fn member_remove(
&mut self,
request: impl tonic::IntoRequest<super::MemberRemoveRequest>,
) -> std::result::Result<
tonic::Response<super::MemberRemoveResponse>,
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(
"/chainfire.v1.Cluster/MemberRemove",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("chainfire.v1.Cluster", "MemberRemove"));
self.inner.unary(req, path, codec).await
}
/// MemberList lists all the members in the cluster
pub async fn member_list(
&mut self,
request: impl tonic::IntoRequest<super::MemberListRequest>,
) -> std::result::Result<
tonic::Response<super::MemberListResponse>,
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(
"/chainfire.v1.Cluster/MemberList",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("chainfire.v1.Cluster", "MemberList"));
self.inner.unary(req, path, codec).await
}
/// Status gets the status of the cluster
pub async fn status(
&mut self,
request: impl tonic::IntoRequest<super::StatusRequest>,
) -> std::result::Result<tonic::Response<super::StatusResponse>, 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(
"/chainfire.v1.Cluster/Status",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("chainfire.v1.Cluster", "Status"));
self.inner.unary(req, path, codec).await
}
}
}
/// Generated server implementations.
pub mod kv_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with KvServer.
#[async_trait]
pub trait Kv: std::marker::Send + std::marker::Sync + 'static {
/// Range gets the keys in the range from the key-value store
async fn range(
&self,
request: tonic::Request<super::RangeRequest>,
) -> std::result::Result<tonic::Response<super::RangeResponse>, tonic::Status>;
/// Put puts the given key into the key-value store
async fn put(
&self,
request: tonic::Request<super::PutRequest>,
) -> std::result::Result<tonic::Response<super::PutResponse>, tonic::Status>;
/// Delete deletes the given range from the key-value store
async fn delete(
&self,
request: tonic::Request<super::DeleteRangeRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteRangeResponse>,
tonic::Status,
>;
/// Txn processes multiple requests in a single transaction
async fn txn(
&self,
request: tonic::Request<super::TxnRequest>,
) -> std::result::Result<tonic::Response<super::TxnResponse>, tonic::Status>;
}
/// Key-Value service
#[derive(Debug)]
pub struct KvServer<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> KvServer<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)
}
/// Enable decompressing requests with the given encoding.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
/// Compress responses with the given encoding, if the client supports it.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[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 KvServer<T>
where
T: Kv,
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() {
"/chainfire.v1.KV/Range" => {
#[allow(non_camel_case_types)]
struct RangeSvc<T: Kv>(pub Arc<T>);
impl<T: Kv> tonic::server::UnaryService<super::RangeRequest>
for RangeSvc<T> {
type Response = super::RangeResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::RangeRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Kv>::range(&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 = RangeSvc(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)
}
"/chainfire.v1.KV/Put" => {
#[allow(non_camel_case_types)]
struct PutSvc<T: Kv>(pub Arc<T>);
impl<T: Kv> tonic::server::UnaryService<super::PutRequest>
for PutSvc<T> {
type Response = super::PutResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::PutRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Kv>::put(&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 = PutSvc(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)
}
"/chainfire.v1.KV/Delete" => {
#[allow(non_camel_case_types)]
struct DeleteSvc<T: Kv>(pub Arc<T>);
impl<T: Kv> tonic::server::UnaryService<super::DeleteRangeRequest>
for DeleteSvc<T> {
type Response = super::DeleteRangeResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DeleteRangeRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Kv>::delete(&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 = DeleteSvc(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)
}
"/chainfire.v1.KV/Txn" => {
#[allow(non_camel_case_types)]
struct TxnSvc<T: Kv>(pub Arc<T>);
impl<T: Kv> tonic::server::UnaryService<super::TxnRequest>
for TxnSvc<T> {
type Response = super::TxnResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TxnRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Kv>::txn(&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 = TxnSvc(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 KvServer<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,
}
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "chainfire.v1.KV";
impl<T> tonic::server::NamedService for KvServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
/// Generated server implementations.
pub mod watch_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with WatchServer.
#[async_trait]
pub trait Watch: std::marker::Send + std::marker::Sync + 'static {
/// Server streaming response type for the Watch method.
type WatchStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::WatchResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
/// Watch watches for events happening or that have happened
async fn watch(
&self,
request: tonic::Request<tonic::Streaming<super::WatchRequest>>,
) -> std::result::Result<tonic::Response<Self::WatchStream>, tonic::Status>;
}
/// Watch service
#[derive(Debug)]
pub struct WatchServer<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> WatchServer<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)
}
/// Enable decompressing requests with the given encoding.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
/// Compress responses with the given encoding, if the client supports it.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[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 WatchServer<T>
where
T: Watch,
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() {
"/chainfire.v1.Watch/Watch" => {
#[allow(non_camel_case_types)]
struct WatchSvc<T: Watch>(pub Arc<T>);
impl<T: Watch> tonic::server::StreamingService<super::WatchRequest>
for WatchSvc<T> {
type Response = super::WatchResponse;
type ResponseStream = T::WatchStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::WatchRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Watch>::watch(&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 = WatchSvc(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.streaming(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 WatchServer<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,
}
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "chainfire.v1.Watch";
impl<T> tonic::server::NamedService for WatchServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
/// Generated server implementations.
pub mod cluster_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with ClusterServer.
#[async_trait]
pub trait Cluster: std::marker::Send + std::marker::Sync + 'static {
/// MemberAdd adds a member into the cluster
async fn member_add(
&self,
request: tonic::Request<super::MemberAddRequest>,
) -> std::result::Result<
tonic::Response<super::MemberAddResponse>,
tonic::Status,
>;
/// MemberRemove removes an existing member from the cluster
async fn member_remove(
&self,
request: tonic::Request<super::MemberRemoveRequest>,
) -> std::result::Result<
tonic::Response<super::MemberRemoveResponse>,
tonic::Status,
>;
/// MemberList lists all the members in the cluster
async fn member_list(
&self,
request: tonic::Request<super::MemberListRequest>,
) -> std::result::Result<
tonic::Response<super::MemberListResponse>,
tonic::Status,
>;
/// Status gets the status of the cluster
async fn status(
&self,
request: tonic::Request<super::StatusRequest>,
) -> std::result::Result<tonic::Response<super::StatusResponse>, tonic::Status>;
}
/// Cluster management service
#[derive(Debug)]
pub struct ClusterServer<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> ClusterServer<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)
}
/// Enable decompressing requests with the given encoding.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
/// Compress responses with the given encoding, if the client supports it.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[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 ClusterServer<T>
where
T: Cluster,
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() {
"/chainfire.v1.Cluster/MemberAdd" => {
#[allow(non_camel_case_types)]
struct MemberAddSvc<T: Cluster>(pub Arc<T>);
impl<T: Cluster> tonic::server::UnaryService<super::MemberAddRequest>
for MemberAddSvc<T> {
type Response = super::MemberAddResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MemberAddRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Cluster>::member_add(&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 = MemberAddSvc(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)
}
"/chainfire.v1.Cluster/MemberRemove" => {
#[allow(non_camel_case_types)]
struct MemberRemoveSvc<T: Cluster>(pub Arc<T>);
impl<
T: Cluster,
> tonic::server::UnaryService<super::MemberRemoveRequest>
for MemberRemoveSvc<T> {
type Response = super::MemberRemoveResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MemberRemoveRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Cluster>::member_remove(&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 = MemberRemoveSvc(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)
}
"/chainfire.v1.Cluster/MemberList" => {
#[allow(non_camel_case_types)]
struct MemberListSvc<T: Cluster>(pub Arc<T>);
impl<
T: Cluster,
> tonic::server::UnaryService<super::MemberListRequest>
for MemberListSvc<T> {
type Response = super::MemberListResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MemberListRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Cluster>::member_list(&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 = MemberListSvc(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)
}
"/chainfire.v1.Cluster/Status" => {
#[allow(non_camel_case_types)]
struct StatusSvc<T: Cluster>(pub Arc<T>);
impl<T: Cluster> tonic::server::UnaryService<super::StatusRequest>
for StatusSvc<T> {
type Response = super::StatusResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StatusRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Cluster>::status(&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 = StatusSvc(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 ClusterServer<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,
}
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "chainfire.v1.Cluster";
impl<T> tonic::server::NamedService for ClusterServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}