#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValue {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(int64, tag = "3")]
pub lease: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Event {
#[prost(enumeration = "event::EventType", tag = "1")]
pub r#type: i32,
#[prost(message, optional, tag = "2")]
pub kv: ::core::option::Option<KeyValue>,
#[prost(message, optional, tag = "3")]
pub prev_kv: ::core::option::Option<KeyValue>,
}
pub mod event {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EventType {
Put = 0,
Delete = 1,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RangeRequest {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
#[prost(int64, tag = "3")]
pub limit: i64,
#[prost(enumeration = "range_request::SortOrder", tag = "4")]
pub sort_order: i32,
#[prost(enumeration = "range_request::SortTarget", tag = "5")]
pub sort_target: i32,
#[prost(bool, tag = "6")]
pub keys_only: bool,
#[prost(bool, tag = "7")]
pub count_only: bool,
}
pub mod range_request {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SortOrder {
None = 0,
Ascend = 1,
Descend = 2,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SortTarget {
Key = 0,
Version = 1,
Create = 2,
Mod = 3,
Value = 4,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RangeResponse {
#[prost(message, repeated, tag = "1")]
pub kvs: ::prost::alloc::vec::Vec<KeyValue>,
#[prost(bool, tag = "2")]
pub more: bool,
#[prost(int64, tag = "3")]
pub count: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutRequest {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(int64, tag = "3")]
pub lease: i64,
#[prost(bool, tag = "4")]
pub prev_kv: bool,
#[prost(bool, tag = "5")]
pub ignore_value: bool,
#[prost(bool, tag = "6")]
pub ignore_lease: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PutResponse {
#[prost(message, optional, tag = "1")]
pub prev_kv: ::core::option::Option<KeyValue>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeRequest {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
#[prost(bool, tag = "3")]
pub prev_kv: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteRangeResponse {
#[prost(int64, tag = "1")]
pub deleted: i64,
#[prost(message, repeated, tag = "2")]
pub prev_kvs: ::prost::alloc::vec::Vec<KeyValue>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestOp {
#[prost(oneof = "request_op::Request", tags = "1, 2, 3, 4")]
pub request: ::core::option::Option<request_op::Request>,
}
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),
#[prost(message, tag = "4")]
RequestTxn(super::TxnRequest),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseOp {
#[prost(oneof = "response_op::Response", tags = "1, 2, 3, 4")]
pub response: ::core::option::Option<response_op::Response>,
}
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),
#[prost(message, tag = "4")]
ResponseTxn(super::TxnResponse),
}
}
#[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(bytes = "vec", tag = "64")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
#[prost(oneof = "compare::TargetUnion", tags = "4, 5, 6, 7, 8")]
pub target_union: ::core::option::Option<compare::TargetUnion>,
}
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,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CompareTarget {
Version = 0,
Create = 1,
Mod = 2,
Value = 3,
Lease = 4,
}
#[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>),
#[prost(int64, tag = "8")]
Lease(i64),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnRequest {
#[prost(message, repeated, tag = "1")]
pub compare: ::prost::alloc::vec::Vec<Compare>,
#[prost(message, repeated, tag = "2")]
pub success: ::prost::alloc::vec::Vec<RequestOp>,
#[prost(message, repeated, tag = "3")]
pub failure: ::prost::alloc::vec::Vec<RequestOp>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TxnResponse {
#[prost(bool, tag = "1")]
pub succeeded: bool,
#[prost(message, repeated, tag = "2")]
pub responses: ::prost::alloc::vec::Vec<ResponseOp>,
}
#[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>,
}
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 {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub range_end: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "watch_create_request::FilterType", repeated, tag = "3")]
pub filters: ::prost::alloc::vec::Vec<i32>,
#[prost(bool, tag = "4")]
pub prev_kv: bool,
#[prost(int64, tag = "5")]
pub watch_id: i64,
}
pub mod watch_create_request {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum FilterType {
Noput = 0,
Nodelete = 1,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchCancelRequest {
#[prost(int64, tag = "1")]
pub watch_id: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchProgressRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WatchResponse {
#[prost(int64, tag = "1")]
pub watch_id: i64,
#[prost(bool, tag = "2")]
pub created: bool,
#[prost(bool, tag = "3")]
pub canceled: bool,
#[prost(int64, tag = "4")]
pub compact_revision: i64,
#[prost(string, tag = "5")]
pub cancel_reason: ::prost::alloc::string::String,
#[prost(bool, tag = "6")]
pub fragment: bool,
#[prost(message, repeated, tag = "7")]
pub events: ::prost::alloc::vec::Vec<Event>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseGrantRequest {
#[prost(int64, tag = "1")]
pub ttl: i64,
#[prost(int64, tag = "2")]
pub id: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseGrantResponse {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(int64, tag = "2")]
pub ttl: i64,
#[prost(string, tag = "3")]
pub error: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseRevokeRequest {
#[prost(int64, tag = "1")]
pub id: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseRevokeResponse {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseKeepAliveRequest {
#[prost(int64, tag = "1")]
pub id: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseKeepAliveResponse {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(int64, tag = "2")]
pub ttl: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseTimeToLiveRequest {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(bool, tag = "2")]
pub keys: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseTimeToLiveResponse {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(int64, tag = "2")]
pub ttl: i64,
#[prost(int64, tag = "3")]
pub granted_ttl: i64,
#[prost(bytes = "vec", repeated, tag = "4")]
pub keys: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseLeasesRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseStatus {
#[prost(int64, tag = "1")]
pub id: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaseLeasesResponse {
#[prost(message, repeated, tag = "1")]
pub leases: ::prost::alloc::vec::Vec<LeaseStatus>,
}
#[doc = r" Generated client implementations."]
pub mod kv_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[derive(Debug, Clone)]
pub struct KvClient<T> {
inner: tonic::client::Grpc<T>,
}
impl KvClient<tonic::transport::Channel> {
#[doc = r" 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: std::convert::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::ResponseBody: Body + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor<F>(inner: T, interceptor: F) -> KvClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
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> + Send + Sync,
{
KvClient::new(InterceptedService::new(inner, interceptor))
}
#[doc = r" Compress requests with `gzip`."]
#[doc = r""]
#[doc = r" This requires the server to support it otherwise it might respond with an"]
#[doc = r" error."]
pub fn send_gzip(mut self) -> Self {
self.inner = self.inner.send_gzip();
self
}
#[doc = r" Enable decompressing responses with `gzip`."]
pub fn accept_gzip(mut self) -> Self {
self.inner = self.inner.accept_gzip();
self
}
#[doc = " Range gets the keys in the range from the key-value store."]
pub async fn range(
&mut self,
request: impl tonic::IntoRequest<super::RangeRequest>,
) -> Result<tonic::Response<super::RangeResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.KV/Range");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Put puts the given key into the key-value store."]
#[doc = " A put request increments the revision of the key-value store"]
#[doc = " and generates one event in the event history."]
pub async fn put(
&mut self,
request: impl tonic::IntoRequest<super::PutRequest>,
) -> Result<tonic::Response<super::PutResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.KV/Put");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " DeleteRange deletes the given range from the key-value store."]
#[doc = " A delete request increments the revision of the key-value store"]
#[doc = " and generates a delete event in the event history for every deleted key."]
pub async fn delete_range(
&mut self,
request: impl tonic::IntoRequest<super::DeleteRangeRequest>,
) -> Result<tonic::Response<super::DeleteRangeResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.KV/DeleteRange");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Txn processes multiple requests in a single transaction."]
#[doc = " A txn request increments the revision of the key-value store"]
#[doc = " and generates events with the same revision for every completed request."]
#[doc = " It is not allowed to modify the same key several times within one txn."]
pub async fn txn(
&mut self,
request: impl tonic::IntoRequest<super::TxnRequest>,
) -> Result<tonic::Response<super::TxnResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.KV/Txn");
self.inner.unary(request.into_request(), path, codec).await
}
}
}
#[doc = r" Generated client implementations."]
pub mod watch_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[derive(Debug, Clone)]
pub struct WatchClient<T> {
inner: tonic::client::Grpc<T>,
}
impl WatchClient<tonic::transport::Channel> {
#[doc = r" 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: std::convert::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::ResponseBody: Body + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> WatchClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
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> + Send + Sync,
{
WatchClient::new(InterceptedService::new(inner, interceptor))
}
#[doc = r" Compress requests with `gzip`."]
#[doc = r""]
#[doc = r" This requires the server to support it otherwise it might respond with an"]
#[doc = r" error."]
pub fn send_gzip(mut self) -> Self {
self.inner = self.inner.send_gzip();
self
}
#[doc = r" Enable decompressing responses with `gzip`."]
pub fn accept_gzip(mut self) -> Self {
self.inner = self.inner.accept_gzip();
self
}
#[doc = " Watch watches for events happening or that have happened. Both input and output"]
#[doc = " are streams; the input stream is for creating and canceling watchers and the output"]
#[doc = " stream sends events. One watch RPC can watch on multiple key ranges, streaming events"]
#[doc = " for several watches at once. The entire event history can be watched starting from the"]
#[doc = " last compaction revision."]
pub async fn watch(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::WatchRequest>,
) -> Result<tonic::Response<tonic::codec::Streaming<super::WatchResponse>>, tonic::Status>
{
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Watch/Watch");
self.inner
.streaming(request.into_streaming_request(), path, codec)
.await
}
}
}
#[doc = r" Generated client implementations."]
pub mod lease_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[derive(Debug, Clone)]
pub struct LeaseClient<T> {
inner: tonic::client::Grpc<T>,
}
impl LeaseClient<tonic::transport::Channel> {
#[doc = r" 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: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> LeaseClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::ResponseBody: Body + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> LeaseClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
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> + Send + Sync,
{
LeaseClient::new(InterceptedService::new(inner, interceptor))
}
#[doc = r" Compress requests with `gzip`."]
#[doc = r""]
#[doc = r" This requires the server to support it otherwise it might respond with an"]
#[doc = r" error."]
pub fn send_gzip(mut self) -> Self {
self.inner = self.inner.send_gzip();
self
}
#[doc = r" Enable decompressing responses with `gzip`."]
pub fn accept_gzip(mut self) -> Self {
self.inner = self.inner.accept_gzip();
self
}
#[doc = " LeaseGrant creates a lease which expires if the server does not receive a keepAlive"]
#[doc = " within a given time to live period. All keys attached to the lease will be expired and"]
#[doc = " deleted if the lease expires. Each expired key generates a delete event in the event history."]
pub async fn lease_grant(
&mut self,
request: impl tonic::IntoRequest<super::LeaseGrantRequest>,
) -> Result<tonic::Response<super::LeaseGrantResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Lease/LeaseGrant");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted."]
pub async fn lease_revoke(
&mut self,
request: impl tonic::IntoRequest<super::LeaseRevokeRequest>,
) -> Result<tonic::Response<super::LeaseRevokeResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Lease/LeaseRevoke");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client"]
#[doc = " to the server and streaming keep alive responses from the server to the client."]
pub async fn lease_keep_alive(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::LeaseKeepAliveRequest>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::LeaseKeepAliveResponse>>,
tonic::Status,
> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Lease/LeaseKeepAlive");
self.inner
.streaming(request.into_streaming_request(), path, codec)
.await
}
#[doc = " LeaseTimeToLive retrieves lease information."]
pub async fn lease_time_to_live(
&mut self,
request: impl tonic::IntoRequest<super::LeaseTimeToLiveRequest>,
) -> Result<tonic::Response<super::LeaseTimeToLiveResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Lease/LeaseTimeToLive");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " LeaseLeases lists all existing leases."]
pub async fn lease_leases(
&mut self,
request: impl tonic::IntoRequest<super::LeaseLeasesRequest>,
) -> Result<tonic::Response<super::LeaseLeasesResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/galadh.Lease/LeaseLeases");
self.inner.unary(request.into_request(), path, codec).await
}
}
}
#[doc = r" Generated server implementations."]
pub mod kv_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[doc = "Generated trait containing gRPC methods that should be implemented for use with KvServer."]
#[async_trait]
pub trait Kv: Send + Sync + 'static {
#[doc = " Range gets the keys in the range from the key-value store."]
async fn range(
&self,
request: tonic::Request<super::RangeRequest>,
) -> Result<tonic::Response<super::RangeResponse>, tonic::Status>;
#[doc = " Put puts the given key into the key-value store."]
#[doc = " A put request increments the revision of the key-value store"]
#[doc = " and generates one event in the event history."]
async fn put(
&self,
request: tonic::Request<super::PutRequest>,
) -> Result<tonic::Response<super::PutResponse>, tonic::Status>;
#[doc = " DeleteRange deletes the given range from the key-value store."]
#[doc = " A delete request increments the revision of the key-value store"]
#[doc = " and generates a delete event in the event history for every deleted key."]
async fn delete_range(
&self,
request: tonic::Request<super::DeleteRangeRequest>,
) -> Result<tonic::Response<super::DeleteRangeResponse>, tonic::Status>;
#[doc = " Txn processes multiple requests in a single transaction."]
#[doc = " A txn request increments the revision of the key-value store"]
#[doc = " and generates events with the same revision for every completed request."]
#[doc = " It is not allowed to modify the same key several times within one txn."]
async fn txn(
&self,
request: tonic::Request<super::TxnRequest>,
) -> Result<tonic::Response<super::TxnResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct KvServer<T: Kv> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
}
struct _Inner<T>(Arc<T>);
impl<T: Kv> KvServer<T> {
pub fn new(inner: T) -> Self {
let inner = Arc::new(inner);
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for KvServer<T>
where
T: Kv,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = Never;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/galadh.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 = self.0.clone();
let fut = async move { (*inner).range(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
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,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.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 = self.0.clone();
let fut = async move { (*inner).put(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
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,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.KV/DeleteRange" => {
#[allow(non_camel_case_types)]
struct DeleteRangeSvc<T: Kv>(pub Arc<T>);
impl<T: Kv> tonic::server::UnaryService<super::DeleteRangeRequest> for DeleteRangeSvc<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 = self.0.clone();
let fut = async move { (*inner).delete_range(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = DeleteRangeSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.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 = self.0.clone();
let fut = async move { (*inner).txn(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
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,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => Box::pin(async move {
Ok(http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap())
}),
}
}
}
impl<T: Kv> 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,
}
}
}
impl<T: Kv> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Kv> tonic::transport::NamedService for KvServer<T> {
const NAME: &'static str = "galadh.KV";
}
}
#[doc = r" Generated server implementations."]
pub mod watch_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[doc = "Generated trait containing gRPC methods that should be implemented for use with WatchServer."]
#[async_trait]
pub trait Watch: Send + Sync + 'static {
#[doc = "Server streaming response type for the Watch method."]
type WatchStream: futures_core::Stream<Item = Result<super::WatchResponse, tonic::Status>>
+ Send
+ 'static;
#[doc = " Watch watches for events happening or that have happened. Both input and output"]
#[doc = " are streams; the input stream is for creating and canceling watchers and the output"]
#[doc = " stream sends events. One watch RPC can watch on multiple key ranges, streaming events"]
#[doc = " for several watches at once. The entire event history can be watched starting from the"]
#[doc = " last compaction revision."]
async fn watch(
&self,
request: tonic::Request<tonic::Streaming<super::WatchRequest>>,
) -> Result<tonic::Response<Self::WatchStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct WatchServer<T: Watch> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
}
struct _Inner<T>(Arc<T>);
impl<T: Watch> WatchServer<T> {
pub fn new(inner: T) -> Self {
let inner = Arc::new(inner);
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for WatchServer<T>
where
T: Watch,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = Never;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/galadh.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 = self.0.clone();
let fut = async move { (*inner).watch(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
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,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => Box::pin(async move {
Ok(http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap())
}),
}
}
}
impl<T: Watch> 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,
}
}
}
impl<T: Watch> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Watch> tonic::transport::NamedService for WatchServer<T> {
const NAME: &'static str = "galadh.Watch";
}
}
#[doc = r" Generated server implementations."]
pub mod lease_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[doc = "Generated trait containing gRPC methods that should be implemented for use with LeaseServer."]
#[async_trait]
pub trait Lease: Send + Sync + 'static {
#[doc = " LeaseGrant creates a lease which expires if the server does not receive a keepAlive"]
#[doc = " within a given time to live period. All keys attached to the lease will be expired and"]
#[doc = " deleted if the lease expires. Each expired key generates a delete event in the event history."]
async fn lease_grant(
&self,
request: tonic::Request<super::LeaseGrantRequest>,
) -> Result<tonic::Response<super::LeaseGrantResponse>, tonic::Status>;
#[doc = " LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted."]
async fn lease_revoke(
&self,
request: tonic::Request<super::LeaseRevokeRequest>,
) -> Result<tonic::Response<super::LeaseRevokeResponse>, tonic::Status>;
#[doc = "Server streaming response type for the LeaseKeepAlive method."]
type LeaseKeepAliveStream: futures_core::Stream<Item = Result<super::LeaseKeepAliveResponse, tonic::Status>>
+ Send
+ 'static;
#[doc = " LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client"]
#[doc = " to the server and streaming keep alive responses from the server to the client."]
async fn lease_keep_alive(
&self,
request: tonic::Request<tonic::Streaming<super::LeaseKeepAliveRequest>>,
) -> Result<tonic::Response<Self::LeaseKeepAliveStream>, tonic::Status>;
#[doc = " LeaseTimeToLive retrieves lease information."]
async fn lease_time_to_live(
&self,
request: tonic::Request<super::LeaseTimeToLiveRequest>,
) -> Result<tonic::Response<super::LeaseTimeToLiveResponse>, tonic::Status>;
#[doc = " LeaseLeases lists all existing leases."]
async fn lease_leases(
&self,
request: tonic::Request<super::LeaseLeasesRequest>,
) -> Result<tonic::Response<super::LeaseLeasesResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct LeaseServer<T: Lease> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
}
struct _Inner<T>(Arc<T>);
impl<T: Lease> LeaseServer<T> {
pub fn new(inner: T) -> Self {
let inner = Arc::new(inner);
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for LeaseServer<T>
where
T: Lease,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = Never;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/galadh.Lease/LeaseGrant" => {
#[allow(non_camel_case_types)]
struct LeaseGrantSvc<T: Lease>(pub Arc<T>);
impl<T: Lease> tonic::server::UnaryService<super::LeaseGrantRequest> for LeaseGrantSvc<T> {
type Response = super::LeaseGrantResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::LeaseGrantRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).lease_grant(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaseGrantSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.Lease/LeaseRevoke" => {
#[allow(non_camel_case_types)]
struct LeaseRevokeSvc<T: Lease>(pub Arc<T>);
impl<T: Lease> tonic::server::UnaryService<super::LeaseRevokeRequest> for LeaseRevokeSvc<T> {
type Response = super::LeaseRevokeResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::LeaseRevokeRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).lease_revoke(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaseRevokeSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.Lease/LeaseKeepAlive" => {
#[allow(non_camel_case_types)]
struct LeaseKeepAliveSvc<T: Lease>(pub Arc<T>);
impl<T: Lease> tonic::server::StreamingService<super::LeaseKeepAliveRequest>
for LeaseKeepAliveSvc<T>
{
type Response = super::LeaseKeepAliveResponse;
type ResponseStream = T::LeaseKeepAliveStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<tonic::Streaming<super::LeaseKeepAliveRequest>>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).lease_keep_alive(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaseKeepAliveSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.Lease/LeaseTimeToLive" => {
#[allow(non_camel_case_types)]
struct LeaseTimeToLiveSvc<T: Lease>(pub Arc<T>);
impl<T: Lease> tonic::server::UnaryService<super::LeaseTimeToLiveRequest>
for LeaseTimeToLiveSvc<T>
{
type Response = super::LeaseTimeToLiveResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::LeaseTimeToLiveRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).lease_time_to_live(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaseTimeToLiveSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/galadh.Lease/LeaseLeases" => {
#[allow(non_camel_case_types)]
struct LeaseLeasesSvc<T: Lease>(pub Arc<T>);
impl<T: Lease> tonic::server::UnaryService<super::LeaseLeasesRequest> for LeaseLeasesSvc<T> {
type Response = super::LeaseLeasesResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::LeaseLeasesRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).lease_leases(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaseLeasesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => Box::pin(async move {
Ok(http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap())
}),
}
}
}
impl<T: Lease> Clone for LeaseServer<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,
}
}
}
impl<T: Lease> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Lease> tonic::transport::NamedService for LeaseServer<T> {
const NAME: &'static str = "galadh.Lease";
}
}