#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskId {
#[prost(string, tag = "1")]
pub query_id: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub stage_id: u32,
#[prost(uint32, tag = "3")]
pub task_id: u32,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskInfoResponse {
#[prost(message, optional, tag = "1")]
pub task_id: ::core::option::Option<super::batch_plan::TaskId>,
#[prost(enumeration = "task_info_response::TaskStatus", tag = "2")]
pub task_status: i32,
#[prost(string, tag = "3")]
pub error_message: ::prost::alloc::string::String,
}
pub mod task_info_response {
#[derive(prost_helpers::AnyPB)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum TaskStatus {
Unspecified = 0,
Pending = 2,
Running = 3,
Finished = 6,
Failed = 7,
Aborted = 8,
Cancelled = 9,
Ping = 10,
}
impl TaskStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
TaskStatus::Unspecified => "UNSPECIFIED",
TaskStatus::Pending => "PENDING",
TaskStatus::Running => "RUNNING",
TaskStatus::Finished => "FINISHED",
TaskStatus::Failed => "FAILED",
TaskStatus::Aborted => "ABORTED",
TaskStatus::Cancelled => "CANCELLED",
TaskStatus::Ping => "PING",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED" => Some(Self::Unspecified),
"PENDING" => Some(Self::Pending),
"RUNNING" => Some(Self::Running),
"FINISHED" => Some(Self::Finished),
"FAILED" => Some(Self::Failed),
"ABORTED" => Some(Self::Aborted),
"CANCELLED" => Some(Self::Cancelled),
"PING" => Some(Self::Ping),
_ => None,
}
}
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateTaskRequest {
#[prost(message, optional, tag = "1")]
pub task_id: ::core::option::Option<super::batch_plan::TaskId>,
#[prost(message, optional, tag = "2")]
pub plan: ::core::option::Option<super::batch_plan::PlanFragment>,
#[prost(message, optional, tag = "3")]
pub epoch: ::core::option::Option<super::common::BatchQueryEpoch>,
#[prost(map = "string, string", tag = "4")]
pub tracing_context: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, optional, tag = "5")]
pub expr_context: ::core::option::Option<super::plan_common::ExprContext>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CancelTaskRequest {
#[prost(message, optional, tag = "1")]
pub task_id: ::core::option::Option<super::batch_plan::TaskId>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CancelTaskResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetTaskInfoRequest {
#[prost(message, optional, tag = "1")]
pub task_id: ::core::option::Option<super::batch_plan::TaskId>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDataResponse {
#[prost(message, optional, tag = "2")]
pub record_batch: ::core::option::Option<super::data::DataChunk>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecuteRequest {
#[prost(message, optional, tag = "1")]
pub task_id: ::core::option::Option<super::batch_plan::TaskId>,
#[prost(message, optional, tag = "2")]
pub plan: ::core::option::Option<super::batch_plan::PlanFragment>,
#[prost(message, optional, tag = "3")]
pub epoch: ::core::option::Option<super::common::BatchQueryEpoch>,
#[prost(map = "string, string", tag = "4")]
pub tracing_context: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, optional, tag = "5")]
pub expr_context: ::core::option::Option<super::plan_common::ExprContext>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDataRequest {
#[prost(message, optional, tag = "1")]
pub task_output_id: ::core::option::Option<super::batch_plan::TaskOutputId>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Permits {
#[prost(oneof = "permits::Value", tags = "1, 2")]
pub value: ::core::option::Option<permits::Value>,
}
pub mod permits {
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(uint32, tag = "1")]
Record(u32),
#[prost(uint32, tag = "2")]
Barrier(u32),
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetStreamRequest {
#[prost(oneof = "get_stream_request::Value", tags = "1, 2")]
pub value: ::core::option::Option<get_stream_request::Value>,
}
pub mod get_stream_request {
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Get {
#[prost(uint32, tag = "1")]
pub up_actor_id: u32,
#[prost(uint32, tag = "2")]
pub down_actor_id: u32,
#[prost(uint32, tag = "3")]
pub up_fragment_id: u32,
#[prost(uint32, tag = "4")]
pub down_fragment_id: u32,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(message, tag = "1")]
Get(Get),
#[prost(message, tag = "2")]
AddPermits(super::Permits),
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetStreamResponse {
#[prost(message, optional, tag = "1")]
pub message: ::core::option::Option<super::stream_plan::StreamMessage>,
#[prost(message, optional, tag = "2")]
pub permits: ::core::option::Option<Permits>,
}
pub mod task_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct TaskServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TaskServiceClient<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> TaskServiceClient<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,
) -> TaskServiceClient<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,
{
TaskServiceClient::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_task(
&mut self,
request: impl tonic::IntoRequest<super::CreateTaskRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::TaskInfoResponse>>,
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(
"/task_service.TaskService/CreateTask",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("task_service.TaskService", "CreateTask"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn cancel_task(
&mut self,
request: impl tonic::IntoRequest<super::CancelTaskRequest>,
) -> std::result::Result<
tonic::Response<super::CancelTaskResponse>,
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(
"/task_service.TaskService/CancelTask",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("task_service.TaskService", "CancelTask"));
self.inner.unary(req, path, codec).await
}
pub async fn execute(
&mut self,
request: impl tonic::IntoRequest<super::ExecuteRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetDataResponse>>,
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(
"/task_service.TaskService/Execute",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("task_service.TaskService", "Execute"));
self.inner.server_streaming(req, path, codec).await
}
}
}
pub mod exchange_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ExchangeServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ExchangeServiceClient<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> ExchangeServiceClient<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,
) -> ExchangeServiceClient<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,
{
ExchangeServiceClient::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 get_data(
&mut self,
request: impl tonic::IntoRequest<super::GetDataRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetDataResponse>>,
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(
"/task_service.ExchangeService/GetData",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("task_service.ExchangeService", "GetData"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn get_stream(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::GetStreamRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetStreamResponse>>,
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(
"/task_service.ExchangeService/GetStream",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("task_service.ExchangeService", "GetStream"));
self.inner.streaming(req, path, codec).await
}
}
}
pub mod task_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait TaskService: std::marker::Send + std::marker::Sync + 'static {
type CreateTaskStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::TaskInfoResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn create_task(
&self,
request: tonic::Request<super::CreateTaskRequest>,
) -> std::result::Result<tonic::Response<Self::CreateTaskStream>, tonic::Status>;
async fn cancel_task(
&self,
request: tonic::Request<super::CancelTaskRequest>,
) -> std::result::Result<
tonic::Response<super::CancelTaskResponse>,
tonic::Status,
>;
type ExecuteStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::GetDataResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn execute(
&self,
request: tonic::Request<super::ExecuteRequest>,
) -> std::result::Result<tonic::Response<Self::ExecuteStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct TaskServiceServer<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> TaskServiceServer<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 TaskServiceServer<T>
where
T: TaskService,
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() {
"/task_service.TaskService/CreateTask" => {
#[allow(non_camel_case_types)]
struct CreateTaskSvc<T: TaskService>(pub Arc<T>);
impl<
T: TaskService,
> tonic::server::ServerStreamingService<super::CreateTaskRequest>
for CreateTaskSvc<T> {
type Response = super::TaskInfoResponse;
type ResponseStream = T::CreateTaskStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CreateTaskRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TaskService>::create_task(&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 = CreateTaskSvc(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)
}
"/task_service.TaskService/CancelTask" => {
#[allow(non_camel_case_types)]
struct CancelTaskSvc<T: TaskService>(pub Arc<T>);
impl<
T: TaskService,
> tonic::server::UnaryService<super::CancelTaskRequest>
for CancelTaskSvc<T> {
type Response = super::CancelTaskResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CancelTaskRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TaskService>::cancel_task(&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 = CancelTaskSvc(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)
}
"/task_service.TaskService/Execute" => {
#[allow(non_camel_case_types)]
struct ExecuteSvc<T: TaskService>(pub Arc<T>);
impl<
T: TaskService,
> tonic::server::ServerStreamingService<super::ExecuteRequest>
for ExecuteSvc<T> {
type Response = super::GetDataResponse;
type ResponseStream = T::ExecuteStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ExecuteRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TaskService>::execute(&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 = ExecuteSvc(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(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T> Clone for TaskServiceServer<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 = "task_service.TaskService";
impl<T> tonic::server::NamedService for TaskServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod exchange_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait ExchangeService: std::marker::Send + std::marker::Sync + 'static {
type GetDataStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::GetDataResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn get_data(
&self,
request: tonic::Request<super::GetDataRequest>,
) -> std::result::Result<tonic::Response<Self::GetDataStream>, tonic::Status>;
type GetStreamStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::GetStreamResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn get_stream(
&self,
request: tonic::Request<tonic::Streaming<super::GetStreamRequest>>,
) -> std::result::Result<tonic::Response<Self::GetStreamStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct ExchangeServiceServer<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> ExchangeServiceServer<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 ExchangeServiceServer<T>
where
T: ExchangeService,
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() {
"/task_service.ExchangeService/GetData" => {
#[allow(non_camel_case_types)]
struct GetDataSvc<T: ExchangeService>(pub Arc<T>);
impl<
T: ExchangeService,
> tonic::server::ServerStreamingService<super::GetDataRequest>
for GetDataSvc<T> {
type Response = super::GetDataResponse;
type ResponseStream = T::GetDataStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetDataRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ExchangeService>::get_data(&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 = GetDataSvc(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)
}
"/task_service.ExchangeService/GetStream" => {
#[allow(non_camel_case_types)]
struct GetStreamSvc<T: ExchangeService>(pub Arc<T>);
impl<
T: ExchangeService,
> tonic::server::StreamingService<super::GetStreamRequest>
for GetStreamSvc<T> {
type Response = super::GetStreamResponse;
type ResponseStream = T::GetStreamStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::GetStreamRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ExchangeService>::get_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 = GetStreamSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T> Clone for ExchangeServiceServer<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 = "task_service.ExchangeService";
impl<T> tonic::server::NamedService for ExchangeServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}