diff --git a/client b/client index 9d812bd..89e87d7 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 9d812bd1bc7f7ccefd58b5850c4da6435595d8e4 +Subproject commit 89e87d71abf86c2ea727614cd08e8ada71542604 diff --git a/common/build.rs b/common/build.rs index faf1706..8b62bea 100644 --- a/common/build.rs +++ b/common/build.rs @@ -206,6 +206,7 @@ fn main() -> Result<(), Box> { "proto/common.proto", "proto/adresar.proto", "proto/auth.proto", + "proto/backup.proto", "proto/search.proto", "proto/search2.proto", "proto/table_definition.proto", @@ -229,6 +230,7 @@ fn main() -> Result<(), Box> { "proto/common.proto", "proto/adresar.proto", "proto/auth.proto", + "proto/backup.proto", "proto/search.proto", "proto/search2.proto", "proto/table_definition.proto", diff --git a/common/proto/backup.proto b/common/proto/backup.proto new file mode 100644 index 0000000..38bebda --- /dev/null +++ b/common/proto/backup.proto @@ -0,0 +1,67 @@ +syntax = "proto3"; +package komp_ac.backup; + +import "common.proto"; + +service BackupService { + rpc StartBackup(StartBackupRequest) returns (BackupOperationResponse); + rpc StartCheck(komp_ac.common.Empty) returns (BackupOperationResponse); + rpc GetBackupInfo(komp_ac.common.Empty) returns (BackupInfoResponse); + rpc GetOperationStatus(GetOperationStatusRequest) returns (BackupOperationResponse); + rpc RestoreLatest(RestoreLatestRequest) returns (BackupOperationResponse); + rpc RestoreTarget(RestoreTargetRequest) returns (BackupOperationResponse); +} + +enum BackupType { + BACKUP_TYPE_UNSPECIFIED = 0; + BACKUP_TYPE_FULL = 1; + BACKUP_TYPE_DIFF = 2; + BACKUP_TYPE_INCR = 3; +} + +enum OperationKind { + OPERATION_KIND_UNSPECIFIED = 0; + OPERATION_KIND_BACKUP = 1; + OPERATION_KIND_CHECK = 2; + OPERATION_KIND_RESTORE = 3; +} + +enum OperationStatus { + OPERATION_STATUS_UNSPECIFIED = 0; + OPERATION_STATUS_RUNNING = 1; + OPERATION_STATUS_SUCCEEDED = 2; + OPERATION_STATUS_FAILED = 3; +} + +message StartBackupRequest { + BackupType backup_type = 1; +} + +message RestoreLatestRequest { + string confirmation = 1; +} + +message RestoreTargetRequest { + string confirmation = 1; + string target_type = 2; + string target = 3; +} + +message GetOperationStatusRequest { + string operation_id = 1; +} + +message BackupOperationResponse { + string operation_id = 1; + OperationKind kind = 2; + OperationStatus status = 3; + string message = 4; + string output = 5; + int64 started_at_unix_seconds = 6; + int64 finished_at_unix_seconds = 7; +} + +message BackupInfoResponse { + bool success = 1; + string output = 2; +} diff --git a/common/src/lib.rs b/common/src/lib.rs index 517b0da..55585ce 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -10,6 +10,9 @@ pub mod proto { pub mod auth { include!("proto/komp_ac.auth.rs"); } + pub mod backup { + include!("proto/komp_ac.backup.rs"); + } pub mod common { include!("proto/komp_ac.common.rs"); } diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 41dd8e3..a98bac9 100644 Binary files a/common/src/proto/descriptor.bin and b/common/src/proto/descriptor.bin differ diff --git a/common/src/proto/komp_ac.backup.rs b/common/src/proto/komp_ac.backup.rs new file mode 100644 index 0000000..7582e4e --- /dev/null +++ b/common/src/proto/komp_ac.backup.rs @@ -0,0 +1,833 @@ +// This file is @generated by prost-build. +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct StartBackupRequest { + #[prost(enumeration = "BackupType", tag = "1")] + pub backup_type: i32, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RestoreLatestRequest { + #[prost(string, tag = "1")] + pub confirmation: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RestoreTargetRequest { + #[prost(string, tag = "1")] + pub confirmation: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub target_type: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub target: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetOperationStatusRequest { + #[prost(string, tag = "1")] + pub operation_id: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct BackupOperationResponse { + #[prost(string, tag = "1")] + pub operation_id: ::prost::alloc::string::String, + #[prost(enumeration = "OperationKind", tag = "2")] + pub kind: i32, + #[prost(enumeration = "OperationStatus", tag = "3")] + pub status: i32, + #[prost(string, tag = "4")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub output: ::prost::alloc::string::String, + #[prost(int64, tag = "6")] + pub started_at_unix_seconds: i64, + #[prost(int64, tag = "7")] + pub finished_at_unix_seconds: i64, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct BackupInfoResponse { + #[prost(bool, tag = "1")] + pub success: bool, + #[prost(string, tag = "2")] + pub output: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum BackupType { + Unspecified = 0, + Full = 1, + Diff = 2, + Incr = 3, +} +impl BackupType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "BACKUP_TYPE_UNSPECIFIED", + Self::Full => "BACKUP_TYPE_FULL", + Self::Diff => "BACKUP_TYPE_DIFF", + Self::Incr => "BACKUP_TYPE_INCR", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "BACKUP_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "BACKUP_TYPE_FULL" => Some(Self::Full), + "BACKUP_TYPE_DIFF" => Some(Self::Diff), + "BACKUP_TYPE_INCR" => Some(Self::Incr), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum OperationKind { + Unspecified = 0, + Backup = 1, + Check = 2, + Restore = 3, +} +impl OperationKind { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "OPERATION_KIND_UNSPECIFIED", + Self::Backup => "OPERATION_KIND_BACKUP", + Self::Check => "OPERATION_KIND_CHECK", + Self::Restore => "OPERATION_KIND_RESTORE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "OPERATION_KIND_UNSPECIFIED" => Some(Self::Unspecified), + "OPERATION_KIND_BACKUP" => Some(Self::Backup), + "OPERATION_KIND_CHECK" => Some(Self::Check), + "OPERATION_KIND_RESTORE" => Some(Self::Restore), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum OperationStatus { + Unspecified = 0, + Running = 1, + Succeeded = 2, + Failed = 3, +} +impl OperationStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "OPERATION_STATUS_UNSPECIFIED", + Self::Running => "OPERATION_STATUS_RUNNING", + Self::Succeeded => "OPERATION_STATUS_SUCCEEDED", + Self::Failed => "OPERATION_STATUS_FAILED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "OPERATION_STATUS_UNSPECIFIED" => Some(Self::Unspecified), + "OPERATION_STATUS_RUNNING" => Some(Self::Running), + "OPERATION_STATUS_SUCCEEDED" => Some(Self::Succeeded), + "OPERATION_STATUS_FAILED" => Some(Self::Failed), + _ => None, + } + } +} +/// Generated client implementations. +pub mod backup_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 BackupServiceClient { + inner: tonic::client::Grpc, + } + impl BackupServiceClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl BackupServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + 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( + inner: T, + interceptor: F, + ) -> BackupServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + BackupServiceClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[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 start_backup( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/StartBackup", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("komp_ac.backup.BackupService", "StartBackup")); + self.inner.unary(req, path, codec).await + } + pub async fn start_check( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/StartCheck", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("komp_ac.backup.BackupService", "StartCheck")); + self.inner.unary(req, path, codec).await + } + pub async fn get_backup_info( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/GetBackupInfo", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "GetBackupInfo"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_operation_status( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/GetOperationStatus", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "GetOperationStatus"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn restore_latest( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/RestoreLatest", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "RestoreLatest"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn restore_target( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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( + "/komp_ac.backup.BackupService/RestoreTarget", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "RestoreTarget"), + ); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod backup_service_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with BackupServiceServer. + #[async_trait] + pub trait BackupService: std::marker::Send + std::marker::Sync + 'static { + async fn start_backup( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn start_check( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_backup_info( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_operation_status( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn restore_latest( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn restore_target( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct BackupServiceServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl BackupServiceServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> 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( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for BackupServiceServer + where + T: BackupService, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/komp_ac.backup.BackupService/StartBackup" => { + #[allow(non_camel_case_types)] + struct StartBackupSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for StartBackupSvc { + type Response = super::BackupOperationResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::start_backup(&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 = StartBackupSvc(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) + } + "/komp_ac.backup.BackupService/StartCheck" => { + #[allow(non_camel_case_types)] + struct StartCheckSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for StartCheckSvc { + type Response = super::BackupOperationResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::start_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 = StartCheckSvc(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) + } + "/komp_ac.backup.BackupService/GetBackupInfo" => { + #[allow(non_camel_case_types)] + struct GetBackupInfoSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for GetBackupInfoSvc { + type Response = super::BackupInfoResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_backup_info(&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 = GetBackupInfoSvc(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) + } + "/komp_ac.backup.BackupService/GetOperationStatus" => { + #[allow(non_camel_case_types)] + struct GetOperationStatusSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for GetOperationStatusSvc { + type Response = super::BackupOperationResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_operation_status(&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 = GetOperationStatusSvc(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) + } + "/komp_ac.backup.BackupService/RestoreLatest" => { + #[allow(non_camel_case_types)] + struct RestoreLatestSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for RestoreLatestSvc { + type Response = super::BackupOperationResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::restore_latest(&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 = RestoreLatestSvc(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) + } + "/komp_ac.backup.BackupService/RestoreTarget" => { + #[allow(non_camel_case_types)] + struct RestoreTargetSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for RestoreTargetSvc { + type Response = super::BackupOperationResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::restore_target(&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 = RestoreTargetSvc(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) + } + _ => { + 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 Clone for BackupServiceServer { + 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, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "komp_ac.backup.BackupService"; + impl tonic::server::NamedService for BackupServiceServer { + const NAME: &'static str = SERVICE_NAME; + } +} diff --git a/server b/server index 8c87da8..a0c8fd1 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 8c87da8d5aabdf8fa6eb9421206aa65672e80d4f +Subproject commit a0c8fd1a77f11dc4b42bf98920b1a5e1c2696e8b