#[derive(
redis_derive::ToRedisArgs,
redis_derive::FromRedisValue,
serde::Serialize,
serde::Deserialize,
utoipa::ToSchema,
utoipa::IntoParams
)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskRequestRecord {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub channel: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub task_data: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub execution_list_id: ::prost::alloc::string::String,
#[prost(bool, tag = "6")]
pub cleanup_on_empty: bool,
#[prost(string, tag = "7")]
pub created_at: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub updated_at: ::prost::alloc::string::String,
}
#[derive(
redis_derive::ToRedisArgs,
redis_derive::FromRedisValue,
serde::Serialize,
serde::Deserialize,
utoipa::ToSchema,
utoipa::IntoParams
)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskExecutionRecord {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub parent_request_id: ::prost::alloc::string::String,
#[prost(enumeration = "TaskExecutionRecordStatus", tag = "4")]
pub status: i32,
#[prost(string, tag = "5")]
pub result: ::prost::alloc::string::String,
#[prost(bool, tag = "6")]
pub is_complete: bool,
#[prost(uint64, tag = "7")]
pub duration_seconds: u64,
#[prost(string, tag = "8")]
pub created_at: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub updated_at: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TaskResultData {
#[prost(string, tag = "1")]
pub execution_id: ::prost::alloc::string::String,
#[prost(enumeration = "TaskExecutionRecordStatus", tag = "2")]
pub status: i32,
#[prost(string, tag = "3")]
pub result: ::prost::alloc::string::String,
#[prost(bool, tag = "4")]
pub is_complete: bool,
#[prost(uint64, tag = "5")]
pub duration_seconds: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FetchTaskRequestRecordRequest {
#[prost(string, tag = "1")]
pub task_request_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FetchTaskExecutionRecordRequest {
#[prost(string, tag = "1")]
pub parent_request_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub task_execution_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitializeTaskRequestRequest {
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub channel: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub task_data: ::prost::alloc::string::String,
#[prost(bool, tag = "6")]
pub cleanup_on_empty: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitializeTaskRequestResponse {
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitializeTaskExecutionRequest {
#[prost(string, tag = "2")]
pub task_request_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub execution_name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitializeTaskExecutionResponse {
#[prost(string, tag = "1")]
pub execution_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateTaskExecutionRequest {
#[prost(string, tag = "1")]
pub parent_request_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub execution_record_id: ::prost::alloc::string::String,
#[prost(enumeration = "TaskExecutionRecordStatus", tag = "3")]
pub status: i32,
#[prost(string, tag = "4")]
pub result: ::prost::alloc::string::String,
#[prost(bool, tag = "5")]
pub is_complete: bool,
#[prost(uint64, tag = "6")]
pub duration_seconds: u64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TaskExecutionRecordStatus {
Unknown = 0,
Initialized = 1,
Queued = 2,
Running = 3,
Success = 4,
Failure = 5,
Cancelled = 6,
}
impl TaskExecutionRecordStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
TaskExecutionRecordStatus::Unknown => "UNKNOWN",
TaskExecutionRecordStatus::Initialized => "INITIALIZED",
TaskExecutionRecordStatus::Queued => "QUEUED",
TaskExecutionRecordStatus::Running => "RUNNING",
TaskExecutionRecordStatus::Success => "SUCCESS",
TaskExecutionRecordStatus::Failure => "FAILURE",
TaskExecutionRecordStatus::Cancelled => "CANCELLED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"INITIALIZED" => Some(Self::Initialized),
"QUEUED" => Some(Self::Queued),
"RUNNING" => Some(Self::Running),
"SUCCESS" => Some(Self::Success),
"FAILURE" => Some(Self::Failure),
"CANCELLED" => Some(Self::Cancelled),
_ => None,
}
}
}
pub mod db_handler_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 DbHandlerClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DbHandlerClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DbHandlerClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_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,
) -> DbHandlerClient<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> + Send + Sync,
{
DbHandlerClient::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
}
pub async fn fetch_task_request_record(
&mut self,
request: impl tonic::IntoRequest<super::FetchTaskRequestRecordRequest>,
) -> Result<tonic::Response<super::TaskRequestRecord>, 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(
"/db.DbHandler/FetchTaskRequestRecord",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn fetch_task_execution_record(
&mut self,
request: impl tonic::IntoRequest<super::FetchTaskExecutionRecordRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, 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(
"/db.DbHandler/FetchTaskExecutionRecord",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn initialize_task_request(
&mut self,
request: impl tonic::IntoRequest<super::InitializeTaskRequestRequest>,
) -> Result<tonic::Response<super::TaskRequestRecord>, 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(
"/db.DbHandler/InitializeTaskRequest",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn initialize_task_execution(
&mut self,
request: impl tonic::IntoRequest<super::InitializeTaskExecutionRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, 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(
"/db.DbHandler/InitializeTaskExecution",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn update_task_execution(
&mut self,
request: impl tonic::IntoRequest<super::UpdateTaskExecutionRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, 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(
"/db.DbHandler/UpdateTaskExecution",
);
self.inner.unary(request.into_request(), path, codec).await
}
}
}
pub mod db_handler_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait DbHandler: Send + Sync + 'static {
async fn fetch_task_request_record(
&self,
request: tonic::Request<super::FetchTaskRequestRecordRequest>,
) -> Result<tonic::Response<super::TaskRequestRecord>, tonic::Status>;
async fn fetch_task_execution_record(
&self,
request: tonic::Request<super::FetchTaskExecutionRecordRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, tonic::Status>;
async fn initialize_task_request(
&self,
request: tonic::Request<super::InitializeTaskRequestRequest>,
) -> Result<tonic::Response<super::TaskRequestRecord>, tonic::Status>;
async fn initialize_task_execution(
&self,
request: tonic::Request<super::InitializeTaskExecutionRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, tonic::Status>;
async fn update_task_execution(
&self,
request: tonic::Request<super::UpdateTaskExecutionRequest>,
) -> Result<tonic::Response<super::TaskExecutionRecord>, tonic::Status>;
}
#[derive(Debug)]
pub struct DbHandlerServer<T: DbHandler> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: DbHandler> DbHandlerServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[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
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for DbHandlerServer<T>
where
T: DbHandler,
B: Body + Send + 'static,
B::Error: Into<StdError> + 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<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/db.DbHandler/FetchTaskRequestRecord" => {
#[allow(non_camel_case_types)]
struct FetchTaskRequestRecordSvc<T: DbHandler>(pub Arc<T>);
impl<
T: DbHandler,
> tonic::server::UnaryService<super::FetchTaskRequestRecordRequest>
for FetchTaskRequestRecordSvc<T> {
type Response = super::TaskRequestRecord;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::FetchTaskRequestRecordRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).fetch_task_request_record(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = FetchTaskRequestRecordSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/db.DbHandler/FetchTaskExecutionRecord" => {
#[allow(non_camel_case_types)]
struct FetchTaskExecutionRecordSvc<T: DbHandler>(pub Arc<T>);
impl<
T: DbHandler,
> tonic::server::UnaryService<super::FetchTaskExecutionRecordRequest>
for FetchTaskExecutionRecordSvc<T> {
type Response = super::TaskExecutionRecord;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::FetchTaskExecutionRecordRequest,
>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).fetch_task_execution_record(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = FetchTaskExecutionRecordSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/db.DbHandler/InitializeTaskRequest" => {
#[allow(non_camel_case_types)]
struct InitializeTaskRequestSvc<T: DbHandler>(pub Arc<T>);
impl<
T: DbHandler,
> tonic::server::UnaryService<super::InitializeTaskRequestRequest>
for InitializeTaskRequestSvc<T> {
type Response = super::TaskRequestRecord;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::InitializeTaskRequestRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).initialize_task_request(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = InitializeTaskRequestSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/db.DbHandler/InitializeTaskExecution" => {
#[allow(non_camel_case_types)]
struct InitializeTaskExecutionSvc<T: DbHandler>(pub Arc<T>);
impl<
T: DbHandler,
> tonic::server::UnaryService<super::InitializeTaskExecutionRequest>
for InitializeTaskExecutionSvc<T> {
type Response = super::TaskExecutionRecord;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::InitializeTaskExecutionRequest,
>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).initialize_task_execution(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = InitializeTaskExecutionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/db.DbHandler/UpdateTaskExecution" => {
#[allow(non_camel_case_types)]
struct UpdateTaskExecutionSvc<T: DbHandler>(pub Arc<T>);
impl<
T: DbHandler,
> tonic::server::UnaryService<super::UpdateTaskExecutionRequest>
for UpdateTaskExecutionSvc<T> {
type Response = super::TaskExecutionRecord;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::UpdateTaskExecutionRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).update_task_execution(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = UpdateTaskExecutionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: DbHandler> Clone for DbHandlerServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
}
}
}
impl<T: DbHandler> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: DbHandler> tonic::server::NamedService for DbHandlerServer<T> {
const NAME: &'static str = "db.DbHandler";
}
}