// 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, /// 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, /// 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, /// range_end is the upper bound on the requested range #[prost(bytes = "vec", tag = "2")] pub range_end: ::prost::alloc::vec::Vec, /// 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, /// kvs is the list of key-value pairs matched by the range request #[prost(message, repeated, tag = "2")] pub kvs: ::prost::alloc::vec::Vec, /// 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, /// value is the value to put #[prost(bytes = "vec", tag = "2")] pub value: ::prost::alloc::vec::Vec, /// 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, /// prev_kv is the key-value pair before the put #[prost(message, optional, tag = "2")] pub prev_kv: ::core::option::Option, } #[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, /// range_end is the key following the last key to delete #[prost(bytes = "vec", tag = "2")] pub range_end: ::prost::alloc::vec::Vec, /// 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, /// 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, } #[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, /// success is a list of operations to apply if all comparisons succeed #[prost(message, repeated, tag = "2")] pub success: ::prost::alloc::vec::Vec, /// failure is a list of operations to apply if any comparison fails #[prost(message, repeated, tag = "3")] pub failure: ::prost::alloc::vec::Vec, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct TxnResponse { #[prost(message, optional, tag = "1")] pub header: ::core::option::Option, /// 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, } #[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, #[prost(oneof = "compare::TargetUnion", tags = "4, 5, 6, 7")] pub target_union: ::core::option::Option, } /// 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 { 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 { 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), } } #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestOp { #[prost(oneof = "request_op::Request", tags = "1, 2, 3")] pub request: ::core::option::Option, } /// 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, } /// 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, } /// 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, /// range_end is the end of the range to watch #[prost(bytes = "vec", tag = "2")] pub range_end: ::prost::alloc::vec::Vec, /// 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, /// 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, } #[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, /// prev_kv is the KeyValue prior to the event #[prost(message, optional, tag = "3")] pub prev_kv: ::core::option::Option, } /// 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 { 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, /// member is the member information for the added member #[prost(message, optional, tag = "2")] pub member: ::core::option::Option, /// members is the list of all members after adding #[prost(message, repeated, tag = "3")] pub members: ::prost::alloc::vec::Vec, } #[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, /// members is the list of all members after removing #[prost(message, repeated, tag = "2")] pub members: ::prost::alloc::vec::Vec, } #[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, /// members is the list of all members #[prost(message, repeated, tag = "2")] pub members: ::prost::alloc::vec::Vec, } #[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, /// 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 { inner: tonic::client::Grpc, } impl KvClient { /// Attempt to create a new client by connecting to a given endpoint. pub async fn connect(dst: D) -> Result where D: TryInto, D::Error: Into, { let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; Ok(Self::new(conn)) } } impl KvClient where T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + 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( inner: T, interceptor: F, ) -> KvClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, Response = http::Response< >::ResponseBody, >, >, , >>::Error: Into + 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, ) -> std::result::Result, 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, ) -> std::result::Result, 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, ) -> std::result::Result< tonic::Response, 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, ) -> std::result::Result, 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 { inner: tonic::client::Grpc, } impl WatchClient { /// Attempt to create a new client by connecting to a given endpoint. pub async fn connect(dst: D) -> Result where D: TryInto, D::Error: Into, { let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; Ok(Self::new(conn)) } } impl WatchClient where T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + 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( inner: T, interceptor: F, ) -> WatchClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, Response = http::Response< >::ResponseBody, >, >, , >>::Error: Into + 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, ) -> std::result::Result< tonic::Response>, 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 { inner: tonic::client::Grpc, } impl ClusterClient { /// Attempt to create a new client by connecting to a given endpoint. pub async fn connect(dst: D) -> Result where D: TryInto, D::Error: Into, { let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; Ok(Self::new(conn)) } } impl ClusterClient where T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + 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( inner: T, interceptor: F, ) -> ClusterClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, Response = http::Response< >::ResponseBody, >, >, , >>::Error: Into + 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, ) -> std::result::Result< tonic::Response, 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, ) -> std::result::Result< tonic::Response, 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, ) -> std::result::Result< tonic::Response, 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, ) -> std::result::Result, 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, ) -> std::result::Result, tonic::Status>; /// Put puts the given key into the key-value store async fn put( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Delete deletes the given range from the key-value store async fn delete( &self, request: tonic::Request, ) -> std::result::Result< tonic::Response, tonic::Status, >; /// Txn processes multiple requests in a single transaction async fn txn( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; } /// Key-Value service #[derive(Debug)] pub struct KvServer { inner: Arc, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, max_decoding_message_size: Option, max_encoding_message_size: Option, } impl KvServer { pub fn new(inner: T) -> Self { Self::from_arc(Arc::new(inner)) } pub fn from_arc(inner: Arc) -> 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( inner: T, interceptor: F, ) -> InterceptedService 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 tonic::codegen::Service> for KvServer where T: Kv, B: Body + std::marker::Send + 'static, B::Error: Into + std::marker::Send + 'static, { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; fn poll_ready( &mut self, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { "/chainfire.v1.KV/Range" => { #[allow(non_camel_case_types)] struct RangeSvc(pub Arc); impl tonic::server::UnaryService for RangeSvc { type Response = super::RangeResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl tonic::server::UnaryService for PutSvc { type Response = super::PutResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl tonic::server::UnaryService for DeleteSvc { type Response = super::DeleteRangeResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl tonic::server::UnaryService for TxnSvc { type Response = super::TxnResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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 Clone for KvServer { 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 tonic::server::NamedService for KvServer { 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, > + std::marker::Send + 'static; /// Watch watches for events happening or that have happened async fn watch( &self, request: tonic::Request>, ) -> std::result::Result, tonic::Status>; } /// Watch service #[derive(Debug)] pub struct WatchServer { inner: Arc, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, max_decoding_message_size: Option, max_encoding_message_size: Option, } impl WatchServer { pub fn new(inner: T) -> Self { Self::from_arc(Arc::new(inner)) } pub fn from_arc(inner: Arc) -> 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( inner: T, interceptor: F, ) -> InterceptedService 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 tonic::codegen::Service> for WatchServer where T: Watch, B: Body + std::marker::Send + 'static, B::Error: Into + std::marker::Send + 'static, { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; fn poll_ready( &mut self, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { "/chainfire.v1.Watch/Watch" => { #[allow(non_camel_case_types)] struct WatchSvc(pub Arc); impl tonic::server::StreamingService for WatchSvc { type Response = super::WatchResponse; type ResponseStream = T::WatchStream; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request< tonic::Streaming, >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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 Clone for WatchServer { 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 tonic::server::NamedService for WatchServer { 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, ) -> std::result::Result< tonic::Response, tonic::Status, >; /// MemberRemove removes an existing member from the cluster async fn member_remove( &self, request: tonic::Request, ) -> std::result::Result< tonic::Response, tonic::Status, >; /// MemberList lists all the members in the cluster async fn member_list( &self, request: tonic::Request, ) -> std::result::Result< tonic::Response, tonic::Status, >; /// Status gets the status of the cluster async fn status( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; } /// Cluster management service #[derive(Debug)] pub struct ClusterServer { inner: Arc, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, max_decoding_message_size: Option, max_encoding_message_size: Option, } impl ClusterServer { pub fn new(inner: T) -> Self { Self::from_arc(Arc::new(inner)) } pub fn from_arc(inner: Arc) -> 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( inner: T, interceptor: F, ) -> InterceptedService 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 tonic::codegen::Service> for ClusterServer where T: Cluster, B: Body + std::marker::Send + 'static, B::Error: Into + std::marker::Send + 'static, { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; fn poll_ready( &mut self, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { "/chainfire.v1.Cluster/MemberAdd" => { #[allow(non_camel_case_types)] struct MemberAddSvc(pub Arc); impl tonic::server::UnaryService for MemberAddSvc { type Response = super::MemberAddResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl< T: Cluster, > tonic::server::UnaryService for MemberRemoveSvc { type Response = super::MemberRemoveResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl< T: Cluster, > tonic::server::UnaryService for MemberListSvc { type Response = super::MemberListResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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(pub Arc); impl tonic::server::UnaryService for StatusSvc { type Response = super::StatusResponse; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::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 Clone for ClusterServer { 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 tonic::server::NamedService for ClusterServer { const NAME: &'static str = SERVICE_NAME; } }