Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -32,5 +32,19 @@ pub struct SetKeyRequest {
|
||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||
pub struct SetKeyResponse {
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ListenEventsRequest {
|
||||
#[prost(string, tag="1")]
|
||||
pub namespace: ::prost::alloc::string::String,
|
||||
#[prost(string, optional, tag="2")]
|
||||
pub id: ::core::option::Option<::prost::alloc::string::String>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ListenEventsResponse {
|
||||
#[prost(string, tag="1")]
|
||||
pub value: ::prost::alloc::string::String,
|
||||
}
|
||||
include!("churn.v1.tonic.rs");
|
||||
// @@protoc_insertion_point(module)
|
@@ -122,6 +122,31 @@ pub mod churn_client {
|
||||
req.extensions_mut().insert(GrpcMethod::new("churn.v1.Churn", "SetKey"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn listen_events(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ListenEventsRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<tonic::codec::Streaming<super::ListenEventsResponse>>,
|
||||
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(
|
||||
"/churn.v1.Churn/ListenEvents",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(GrpcMethod::new("churn.v1.Churn", "ListenEvents"));
|
||||
self.inner.server_streaming(req, path, codec).await
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Generated server implementations.
|
||||
@@ -139,6 +164,19 @@ pub mod churn_server {
|
||||
&self,
|
||||
request: tonic::Request<super::SetKeyRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::SetKeyResponse>, tonic::Status>;
|
||||
/// Server streaming response type for the ListenEvents method.
|
||||
type ListenEventsStream: tonic::codegen::tokio_stream::Stream<
|
||||
Item = std::result::Result<super::ListenEventsResponse, tonic::Status>,
|
||||
>
|
||||
+ Send
|
||||
+ 'static;
|
||||
async fn listen_events(
|
||||
&self,
|
||||
request: tonic::Request<super::ListenEventsRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<Self::ListenEventsStream>,
|
||||
tonic::Status,
|
||||
>;
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct ChurnServer<T: Churn> {
|
||||
@@ -307,6 +345,53 @@ pub mod churn_server {
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
"/churn.v1.Churn/ListenEvents" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct ListenEventsSvc<T: Churn>(pub Arc<T>);
|
||||
impl<
|
||||
T: Churn,
|
||||
> tonic::server::ServerStreamingService<super::ListenEventsRequest>
|
||||
for ListenEventsSvc<T> {
|
||||
type Response = super::ListenEventsResponse;
|
||||
type ResponseStream = T::ListenEventsStream;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::ResponseStream>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::ListenEventsRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as Churn>::listen_events(&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 inner = inner.0;
|
||||
let method = ListenEventsSvc(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)
|
||||
}
|
||||
_ => {
|
||||
Box::pin(async move {
|
||||
Ok(
|
||||
|
Reference in New Issue
Block a user