#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ReliableOptions {
#[prost(uint64, tag = "1")]
pub segment_size: u64,
#[prost(enumeration = "RetentionPolicy", tag = "4")]
pub retention_policy: i32,
#[prost(uint64, tag = "5")]
pub retention_period: u64,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TopicDispatchStrategy {
#[prost(enumeration = "DispatchStrategy", tag = "1")]
pub strategy: i32,
#[prost(message, optional, tag = "2")]
pub reliable_options: ::core::option::Option<ReliableOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProducerRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(string, tag = "2")]
pub producer_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub topic_name: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub schema: ::core::option::Option<Schema>,
#[prost(enumeration = "ProducerAccessMode", tag = "5")]
pub producer_access_mode: i32,
#[prost(message, optional, tag = "6")]
pub dispatch_strategy: ::core::option::Option<TopicDispatchStrategy>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProducerResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(uint64, tag = "2")]
pub producer_id: u64,
#[prost(string, tag = "3")]
pub producer_name: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct MessageResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(uint64, tag = "2")]
pub sequence_id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConsumerRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(string, tag = "2")]
pub topic_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub consumer_name: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub subscription: ::prost::alloc::string::String,
#[prost(enumeration = "consumer_request::SubscriptionType", tag = "5")]
pub subscription_type: i32,
}
pub mod consumer_request {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum SubscriptionType {
Exclusive = 0,
Shared = 1,
Failover = 2,
}
impl SubscriptionType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Exclusive => "Exclusive",
Self::Shared => "Shared",
Self::Failover => "Failover",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Exclusive" => Some(Self::Exclusive),
"Shared" => Some(Self::Shared),
"Failover" => Some(Self::Failover),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConsumerResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(uint64, tag = "2")]
pub consumer_id: u64,
#[prost(string, tag = "3")]
pub consumer_name: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ReceiveRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(uint64, tag = "2")]
pub consumer_id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamMessage {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(message, optional, tag = "2")]
pub msg_id: ::core::option::Option<MsgId>,
#[prost(bytes = "vec", tag = "3")]
pub payload: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "4")]
pub publish_time: u64,
#[prost(string, tag = "5")]
pub producer_name: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub subscription_name: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "7")]
pub attributes: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgId {
#[prost(uint64, tag = "1")]
pub sequence_id: u64,
#[prost(uint64, tag = "2")]
pub producer_id: u64,
#[prost(string, tag = "3")]
pub topic_name: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub broker_addr: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AckRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(message, optional, tag = "2")]
pub msg_id: ::core::option::Option<MsgId>,
#[prost(string, tag = "3")]
pub subscription_name: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct AckResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TopicLookupRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(string, tag = "2")]
pub topic: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TopicLookupResponse {
#[prost(uint64, tag = "3")]
pub request_id: u64,
#[prost(enumeration = "topic_lookup_response::LookupType", tag = "4")]
pub response_type: i32,
#[prost(string, tag = "5")]
pub broker_service_url: ::prost::alloc::string::String,
}
pub mod topic_lookup_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum LookupType {
Redirect = 0,
Connect = 1,
Failed = 2,
}
impl LookupType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Redirect => "Redirect",
Self::Connect => "Connect",
Self::Failed => "Failed",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Redirect" => Some(Self::Redirect),
"Connect" => Some(Self::Connect),
"Failed" => Some(Self::Failed),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TopicPartitionsResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(string, repeated, tag = "2")]
pub partitions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SchemaRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(string, tag = "2")]
pub topic: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SchemaResponse {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(message, optional, tag = "2")]
pub schema: ::core::option::Option<Schema>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schema {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub schema_data: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "schema::TypeSchema", tag = "4")]
pub type_schema: i32,
}
pub mod schema {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum TypeSchema {
Bytes = 0,
String = 1,
Int64 = 2,
Json = 3,
}
impl TypeSchema {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Bytes => "Bytes",
Self::String => "String",
Self::Int64 => "Int64",
Self::Json => "JSON",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Bytes" => Some(Self::Bytes),
"String" => Some(Self::String),
"Int64" => Some(Self::Int64),
"JSON" => Some(Self::Json),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct HealthCheckRequest {
#[prost(uint64, tag = "1")]
pub request_id: u64,
#[prost(enumeration = "health_check_request::ClientType", tag = "2")]
pub client: i32,
#[prost(uint64, tag = "3")]
pub id: u64,
}
pub mod health_check_request {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ClientType {
Producer = 0,
Consumer = 1,
}
impl ClientType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Producer => "Producer",
Self::Consumer => "Consumer",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Producer" => Some(Self::Producer),
"Consumer" => Some(Self::Consumer),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct HealthCheckResponse {
#[prost(enumeration = "health_check_response::ClientStatus", tag = "1")]
pub status: i32,
}
pub mod health_check_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ClientStatus {
Ok = 0,
Close = 1,
}
impl ClientStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Ok => "OK",
Self::Close => "CLOSE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OK" => Some(Self::Ok),
"CLOSE" => Some(Self::Close),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ErrorMessage {
#[prost(enumeration = "ErrorType", tag = "1")]
pub error_type: i32,
#[prost(string, tag = "2")]
pub error_message: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub redirect_to: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ProducerAccessMode {
Shared = 0,
Exclusive = 1,
}
impl ProducerAccessMode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Shared => "Shared",
Self::Exclusive => "Exclusive",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Shared" => Some(Self::Shared),
"Exclusive" => Some(Self::Exclusive),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DispatchStrategy {
NonReliable = 0,
Reliable = 1,
}
impl DispatchStrategy {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::NonReliable => "NonReliable",
Self::Reliable => "Reliable",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"NonReliable" => Some(Self::NonReliable),
"Reliable" => Some(Self::Reliable),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum RetentionPolicy {
RetainUntilAck = 0,
RetainUntilExpire = 1,
}
impl RetentionPolicy {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::RetainUntilAck => "RetainUntilAck",
Self::RetainUntilExpire => "RetainUntilExpire",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"RetainUntilAck" => Some(Self::RetainUntilAck),
"RetainUntilExpire" => Some(Self::RetainUntilExpire),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ErrorType {
UnknownError = 0,
InvalidTopicName = 1,
TopicNotFound = 2,
ServiceNotReady = 3,
ProducerAlreadyExists = 4,
SubscribePermissionDenied = 5,
SubscriptionNotFound = 6,
}
impl ErrorType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::UnknownError => "UNKNOWN_ERROR",
Self::InvalidTopicName => "INVALID_TOPIC_NAME",
Self::TopicNotFound => "TOPIC_NOT_FOUND",
Self::ServiceNotReady => "SERVICE_NOT_READY",
Self::ProducerAlreadyExists => "PRODUCER_ALREADY_EXISTS",
Self::SubscribePermissionDenied => "SUBSCRIBE_PERMISSION_DENIED",
Self::SubscriptionNotFound => "SUBSCRIPTION_NOT_FOUND",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN_ERROR" => Some(Self::UnknownError),
"INVALID_TOPIC_NAME" => Some(Self::InvalidTopicName),
"TOPIC_NOT_FOUND" => Some(Self::TopicNotFound),
"SERVICE_NOT_READY" => Some(Self::ServiceNotReady),
"PRODUCER_ALREADY_EXISTS" => Some(Self::ProducerAlreadyExists),
"SUBSCRIBE_PERMISSION_DENIED" => Some(Self::SubscribePermissionDenied),
"SUBSCRIPTION_NOT_FOUND" => Some(Self::SubscriptionNotFound),
_ => None,
}
}
}
pub mod producer_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ProducerServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ProducerServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ProducerServiceClient<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,
) -> ProducerServiceClient<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,
{
ProducerServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn create_producer(
&mut self,
request: impl tonic::IntoRequest<super::ProducerRequest>,
) -> std::result::Result<
tonic::Response<super::ProducerResponse>,
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(
"/danube.ProducerService/CreateProducer",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.ProducerService", "CreateProducer"));
self.inner.unary(req, path, codec).await
}
pub async fn send_message(
&mut self,
request: impl tonic::IntoRequest<super::StreamMessage>,
) -> std::result::Result<
tonic::Response<super::MessageResponse>,
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(
"/danube.ProducerService/SendMessage",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.ProducerService", "SendMessage"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod consumer_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ConsumerServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ConsumerServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ConsumerServiceClient<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,
) -> ConsumerServiceClient<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,
{
ConsumerServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn subscribe(
&mut self,
request: impl tonic::IntoRequest<super::ConsumerRequest>,
) -> std::result::Result<
tonic::Response<super::ConsumerResponse>,
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(
"/danube.ConsumerService/Subscribe",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.ConsumerService", "Subscribe"));
self.inner.unary(req, path, codec).await
}
pub async fn receive_messages(
&mut self,
request: impl tonic::IntoRequest<super::ReceiveRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::StreamMessage>>,
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(
"/danube.ConsumerService/ReceiveMessages",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.ConsumerService", "ReceiveMessages"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn ack(
&mut self,
request: impl tonic::IntoRequest<super::AckRequest>,
) -> std::result::Result<tonic::Response<super::AckResponse>, 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(
"/danube.ConsumerService/Ack",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.ConsumerService", "Ack"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod discovery_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct DiscoveryClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DiscoveryClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DiscoveryClient<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,
) -> DiscoveryClient<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,
{
DiscoveryClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn topic_lookup(
&mut self,
request: impl tonic::IntoRequest<super::TopicLookupRequest>,
) -> std::result::Result<
tonic::Response<super::TopicLookupResponse>,
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(
"/danube.Discovery/TopicLookup",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.Discovery", "TopicLookup"));
self.inner.unary(req, path, codec).await
}
pub async fn topic_partitions(
&mut self,
request: impl tonic::IntoRequest<super::TopicLookupRequest>,
) -> std::result::Result<
tonic::Response<super::TopicPartitionsResponse>,
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(
"/danube.Discovery/TopicPartitions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.Discovery", "TopicPartitions"));
self.inner.unary(req, path, codec).await
}
pub async fn get_schema(
&mut self,
request: impl tonic::IntoRequest<super::SchemaRequest>,
) -> std::result::Result<tonic::Response<super::SchemaResponse>, 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(
"/danube.Discovery/GetSchema",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.Discovery", "GetSchema"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod health_check_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct HealthCheckClient<T> {
inner: tonic::client::Grpc<T>,
}
impl HealthCheckClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> HealthCheckClient<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,
) -> HealthCheckClient<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,
{
HealthCheckClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn health_check(
&mut self,
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
) -> std::result::Result<
tonic::Response<super::HealthCheckResponse>,
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(
"/danube.HealthCheck/HealthCheck",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("danube.HealthCheck", "HealthCheck"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod producer_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait ProducerService: std::marker::Send + std::marker::Sync + 'static {
async fn create_producer(
&self,
request: tonic::Request<super::ProducerRequest>,
) -> std::result::Result<
tonic::Response<super::ProducerResponse>,
tonic::Status,
>;
async fn send_message(
&self,
request: tonic::Request<super::StreamMessage>,
) -> std::result::Result<tonic::Response<super::MessageResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct ProducerServiceServer<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> ProducerServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for ProducerServiceServer<T>
where
T: ProducerService,
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() {
"/danube.ProducerService/CreateProducer" => {
#[allow(non_camel_case_types)]
struct CreateProducerSvc<T: ProducerService>(pub Arc<T>);
impl<
T: ProducerService,
> tonic::server::UnaryService<super::ProducerRequest>
for CreateProducerSvc<T> {
type Response = super::ProducerResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ProducerRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ProducerService>::create_producer(&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 = CreateProducerSvc(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)
}
"/danube.ProducerService/SendMessage" => {
#[allow(non_camel_case_types)]
struct SendMessageSvc<T: ProducerService>(pub Arc<T>);
impl<
T: ProducerService,
> tonic::server::UnaryService<super::StreamMessage>
for SendMessageSvc<T> {
type Response = super::MessageResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StreamMessage>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ProducerService>::send_message(&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 = SendMessageSvc(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 ProducerServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "danube.ProducerService";
impl<T> tonic::server::NamedService for ProducerServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod consumer_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait ConsumerService: std::marker::Send + std::marker::Sync + 'static {
async fn subscribe(
&self,
request: tonic::Request<super::ConsumerRequest>,
) -> std::result::Result<
tonic::Response<super::ConsumerResponse>,
tonic::Status,
>;
type ReceiveMessagesStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::StreamMessage, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn receive_messages(
&self,
request: tonic::Request<super::ReceiveRequest>,
) -> std::result::Result<
tonic::Response<Self::ReceiveMessagesStream>,
tonic::Status,
>;
async fn ack(
&self,
request: tonic::Request<super::AckRequest>,
) -> std::result::Result<tonic::Response<super::AckResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct ConsumerServiceServer<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> ConsumerServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for ConsumerServiceServer<T>
where
T: ConsumerService,
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() {
"/danube.ConsumerService/Subscribe" => {
#[allow(non_camel_case_types)]
struct SubscribeSvc<T: ConsumerService>(pub Arc<T>);
impl<
T: ConsumerService,
> tonic::server::UnaryService<super::ConsumerRequest>
for SubscribeSvc<T> {
type Response = super::ConsumerResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ConsumerRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ConsumerService>::subscribe(&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 = SubscribeSvc(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)
}
"/danube.ConsumerService/ReceiveMessages" => {
#[allow(non_camel_case_types)]
struct ReceiveMessagesSvc<T: ConsumerService>(pub Arc<T>);
impl<
T: ConsumerService,
> tonic::server::ServerStreamingService<super::ReceiveRequest>
for ReceiveMessagesSvc<T> {
type Response = super::StreamMessage;
type ResponseStream = T::ReceiveMessagesStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ReceiveRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ConsumerService>::receive_messages(&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 = ReceiveMessagesSvc(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.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/danube.ConsumerService/Ack" => {
#[allow(non_camel_case_types)]
struct AckSvc<T: ConsumerService>(pub Arc<T>);
impl<
T: ConsumerService,
> tonic::server::UnaryService<super::AckRequest> for AckSvc<T> {
type Response = super::AckResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AckRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ConsumerService>::ack(&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 = AckSvc(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 ConsumerServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "danube.ConsumerService";
impl<T> tonic::server::NamedService for ConsumerServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod discovery_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait Discovery: std::marker::Send + std::marker::Sync + 'static {
async fn topic_lookup(
&self,
request: tonic::Request<super::TopicLookupRequest>,
) -> std::result::Result<
tonic::Response<super::TopicLookupResponse>,
tonic::Status,
>;
async fn topic_partitions(
&self,
request: tonic::Request<super::TopicLookupRequest>,
) -> std::result::Result<
tonic::Response<super::TopicPartitionsResponse>,
tonic::Status,
>;
async fn get_schema(
&self,
request: tonic::Request<super::SchemaRequest>,
) -> std::result::Result<tonic::Response<super::SchemaResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct DiscoveryServer<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> DiscoveryServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for DiscoveryServer<T>
where
T: Discovery,
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() {
"/danube.Discovery/TopicLookup" => {
#[allow(non_camel_case_types)]
struct TopicLookupSvc<T: Discovery>(pub Arc<T>);
impl<
T: Discovery,
> tonic::server::UnaryService<super::TopicLookupRequest>
for TopicLookupSvc<T> {
type Response = super::TopicLookupResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TopicLookupRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Discovery>::topic_lookup(&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 = TopicLookupSvc(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)
}
"/danube.Discovery/TopicPartitions" => {
#[allow(non_camel_case_types)]
struct TopicPartitionsSvc<T: Discovery>(pub Arc<T>);
impl<
T: Discovery,
> tonic::server::UnaryService<super::TopicLookupRequest>
for TopicPartitionsSvc<T> {
type Response = super::TopicPartitionsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TopicLookupRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Discovery>::topic_partitions(&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 = TopicPartitionsSvc(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)
}
"/danube.Discovery/GetSchema" => {
#[allow(non_camel_case_types)]
struct GetSchemaSvc<T: Discovery>(pub Arc<T>);
impl<T: Discovery> tonic::server::UnaryService<super::SchemaRequest>
for GetSchemaSvc<T> {
type Response = super::SchemaResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::SchemaRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Discovery>::get_schema(&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 = GetSchemaSvc(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 DiscoveryServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "danube.Discovery";
impl<T> tonic::server::NamedService for DiscoveryServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod health_check_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait HealthCheck: std::marker::Send + std::marker::Sync + 'static {
async fn health_check(
&self,
request: tonic::Request<super::HealthCheckRequest>,
) -> std::result::Result<
tonic::Response<super::HealthCheckResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct HealthCheckServer<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> HealthCheckServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for HealthCheckServer<T>
where
T: HealthCheck,
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() {
"/danube.HealthCheck/HealthCheck" => {
#[allow(non_camel_case_types)]
struct HealthCheckSvc<T: HealthCheck>(pub Arc<T>);
impl<
T: HealthCheck,
> tonic::server::UnaryService<super::HealthCheckRequest>
for HealthCheckSvc<T> {
type Response = super::HealthCheckResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::HealthCheckRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as HealthCheck>::health_check(&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 = HealthCheckSvc(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 HealthCheckServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "danube.HealthCheck";
impl<T> tonic::server::NamedService for HealthCheckServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}