#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TopicInfo {
#[prost(string, tag = "1")]
pub topic_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub tenant_guid: ::prost::alloc::string::String,
#[prost(bool, tag = "3")]
pub can_publish: bool,
#[prost(bool, tag = "4")]
pub can_subscribe: bool,
#[prost(string, tag = "5")]
pub schema_id: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub rpc_id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TopicRequest {
#[prost(string, tag = "1")]
pub topic_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EventHeader {
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProducerEvent {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub schema_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub payload: ::prost::alloc::vec::Vec<u8>,
#[prost(message, repeated, tag = "4")]
pub headers: ::prost::alloc::vec::Vec<EventHeader>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConsumerEvent {
#[prost(message, optional, tag = "1")]
pub event: ::core::option::Option<ProducerEvent>,
#[prost(bytes = "vec", tag = "2")]
pub replay_id: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PublishResult {
#[prost(bytes = "vec", tag = "1")]
pub replay_id: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "2")]
pub error: ::core::option::Option<Error>,
#[prost(string, tag = "3")]
pub correlation_key: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Error {
#[prost(enumeration = "ErrorCode", tag = "1")]
pub code: i32,
#[prost(string, tag = "2")]
pub msg: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct FetchRequest {
#[prost(string, tag = "1")]
pub topic_name: ::prost::alloc::string::String,
#[prost(enumeration = "ReplayPreset", tag = "2")]
pub replay_preset: i32,
#[prost(bytes = "vec", tag = "3")]
pub replay_id: ::prost::alloc::vec::Vec<u8>,
#[prost(int32, tag = "4")]
pub num_requested: i32,
#[prost(string, tag = "5")]
pub auth_refresh: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FetchResponse {
#[prost(message, repeated, tag = "1")]
pub events: ::prost::alloc::vec::Vec<ConsumerEvent>,
#[prost(bytes = "vec", tag = "2")]
pub latest_replay_id: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "3")]
pub rpc_id: ::prost::alloc::string::String,
#[prost(int32, tag = "4")]
pub pending_num_requested: i32,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SchemaRequest {
#[prost(string, tag = "1")]
pub schema_id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SchemaInfo {
#[prost(string, tag = "1")]
pub schema_json: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub schema_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub rpc_id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishRequest {
#[prost(string, tag = "1")]
pub topic_name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub events: ::prost::alloc::vec::Vec<ProducerEvent>,
#[prost(string, tag = "3")]
pub auth_refresh: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishResponse {
#[prost(message, repeated, tag = "1")]
pub results: ::prost::alloc::vec::Vec<PublishResult>,
#[prost(string, tag = "2")]
pub schema_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub rpc_id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ManagedFetchRequest {
#[prost(string, tag = "1")]
pub subscription_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub developer_name: ::prost::alloc::string::String,
#[prost(int32, tag = "3")]
pub num_requested: i32,
#[prost(string, tag = "4")]
pub auth_refresh: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub commit_replay_id_request: ::core::option::Option<CommitReplayRequest>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ManagedFetchResponse {
#[prost(message, repeated, tag = "1")]
pub events: ::prost::alloc::vec::Vec<ConsumerEvent>,
#[prost(bytes = "vec", tag = "2")]
pub latest_replay_id: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag = "3")]
pub rpc_id: ::prost::alloc::string::String,
#[prost(int32, tag = "4")]
pub pending_num_requested: i32,
#[prost(message, optional, tag = "5")]
pub commit_response: ::core::option::Option<CommitReplayResponse>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommitReplayRequest {
#[prost(string, tag = "1")]
pub commit_request_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub replay_id: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommitReplayResponse {
#[prost(string, tag = "1")]
pub commit_request_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub replay_id: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
#[prost(int64, tag = "4")]
pub process_time: i64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ErrorCode {
Unknown = 0,
Publish = 1,
Commit = 2,
}
impl ErrorCode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unknown => "UNKNOWN",
Self::Publish => "PUBLISH",
Self::Commit => "COMMIT",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"PUBLISH" => Some(Self::Publish),
"COMMIT" => Some(Self::Commit),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ReplayPreset {
Latest = 0,
Earliest = 1,
Custom = 2,
}
impl ReplayPreset {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Latest => "LATEST",
Self::Earliest => "EARLIEST",
Self::Custom => "CUSTOM",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"LATEST" => Some(Self::Latest),
"EARLIEST" => Some(Self::Earliest),
"CUSTOM" => Some(Self::Custom),
_ => None,
}
}
}
pub mod pub_sub_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 PubSubClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> PubSubClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
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,
) -> PubSubClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
PubSubClient::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::IntoStreamingRequest<Message = super::FetchRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::FetchResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/Subscribe",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "Subscribe"));
self.inner.streaming(req, path, codec).await
}
pub async fn get_schema(
&mut self,
request: impl tonic::IntoRequest<super::SchemaRequest>,
) -> std::result::Result<tonic::Response<super::SchemaInfo>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/GetSchema",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "GetSchema"));
self.inner.unary(req, path, codec).await
}
pub async fn get_topic(
&mut self,
request: impl tonic::IntoRequest<super::TopicRequest>,
) -> std::result::Result<tonic::Response<super::TopicInfo>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/GetTopic",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "GetTopic"));
self.inner.unary(req, path, codec).await
}
pub async fn publish(
&mut self,
request: impl tonic::IntoRequest<super::PublishRequest>,
) -> std::result::Result<
tonic::Response<super::PublishResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/Publish",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "Publish"));
self.inner.unary(req, path, codec).await
}
pub async fn publish_stream(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::PublishRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::PublishResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/PublishStream",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "PublishStream"));
self.inner.streaming(req, path, codec).await
}
pub async fn managed_subscribe(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::ManagedFetchRequest,
>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ManagedFetchResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/eventbus.v1.PubSub/ManagedSubscribe",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("eventbus.v1.PubSub", "ManagedSubscribe"));
self.inner.streaming(req, path, codec).await
}
}
}
pub mod pub_sub_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait PubSub: std::marker::Send + std::marker::Sync + 'static {
type SubscribeStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::FetchResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn subscribe(
&self,
request: tonic::Request<tonic::Streaming<super::FetchRequest>>,
) -> std::result::Result<tonic::Response<Self::SubscribeStream>, tonic::Status>;
async fn get_schema(
&self,
request: tonic::Request<super::SchemaRequest>,
) -> std::result::Result<tonic::Response<super::SchemaInfo>, tonic::Status>;
async fn get_topic(
&self,
request: tonic::Request<super::TopicRequest>,
) -> std::result::Result<tonic::Response<super::TopicInfo>, tonic::Status>;
async fn publish(
&self,
request: tonic::Request<super::PublishRequest>,
) -> std::result::Result<tonic::Response<super::PublishResponse>, tonic::Status>;
type PublishStreamStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::PublishResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn publish_stream(
&self,
request: tonic::Request<tonic::Streaming<super::PublishRequest>>,
) -> std::result::Result<
tonic::Response<Self::PublishStreamStream>,
tonic::Status,
>;
type ManagedSubscribeStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::ManagedFetchResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn managed_subscribe(
&self,
request: tonic::Request<tonic::Streaming<super::ManagedFetchRequest>>,
) -> std::result::Result<
tonic::Response<Self::ManagedSubscribeStream>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct PubSubServer<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> PubSubServer<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 PubSubServer<T>
where
T: PubSub,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
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() {
"/eventbus.v1.PubSub/Subscribe" => {
#[allow(non_camel_case_types)]
struct SubscribeSvc<T: PubSub>(pub Arc<T>);
impl<T: PubSub> tonic::server::StreamingService<super::FetchRequest>
for SubscribeSvc<T> {
type Response = super::FetchResponse;
type ResponseStream = T::SubscribeStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::FetchRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as PubSub>::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_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/eventbus.v1.PubSub/GetSchema" => {
#[allow(non_camel_case_types)]
struct GetSchemaSvc<T: PubSub>(pub Arc<T>);
impl<T: PubSub> tonic::server::UnaryService<super::SchemaRequest>
for GetSchemaSvc<T> {
type Response = super::SchemaInfo;
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 PubSub>::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_prost::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)
}
"/eventbus.v1.PubSub/GetTopic" => {
#[allow(non_camel_case_types)]
struct GetTopicSvc<T: PubSub>(pub Arc<T>);
impl<T: PubSub> tonic::server::UnaryService<super::TopicRequest>
for GetTopicSvc<T> {
type Response = super::TopicInfo;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::TopicRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as PubSub>::get_topic(&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 = GetTopicSvc(inner);
let codec = tonic_prost::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)
}
"/eventbus.v1.PubSub/Publish" => {
#[allow(non_camel_case_types)]
struct PublishSvc<T: PubSub>(pub Arc<T>);
impl<T: PubSub> tonic::server::UnaryService<super::PublishRequest>
for PublishSvc<T> {
type Response = super::PublishResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::PublishRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as PubSub>::publish(&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 = PublishSvc(inner);
let codec = tonic_prost::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)
}
"/eventbus.v1.PubSub/PublishStream" => {
#[allow(non_camel_case_types)]
struct PublishStreamSvc<T: PubSub>(pub Arc<T>);
impl<
T: PubSub,
> tonic::server::StreamingService<super::PublishRequest>
for PublishStreamSvc<T> {
type Response = super::PublishResponse;
type ResponseStream = T::PublishStreamStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::PublishRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as PubSub>::publish_stream(&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 = PublishStreamSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/eventbus.v1.PubSub/ManagedSubscribe" => {
#[allow(non_camel_case_types)]
struct ManagedSubscribeSvc<T: PubSub>(pub Arc<T>);
impl<
T: PubSub,
> tonic::server::StreamingService<super::ManagedFetchRequest>
for ManagedSubscribeSvc<T> {
type Response = super::ManagedFetchResponse;
type ResponseStream = T::ManagedSubscribeStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::ManagedFetchRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as PubSub>::managed_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 = ManagedSubscribeSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
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 PubSubServer<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 = "eventbus.v1.PubSub";
impl<T> tonic::server::NamedService for PubSubServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}