From ee509b604174fa1792d073b8052bb04a7820734e Mon Sep 17 00:00:00 2001 From: Priec Date: Mon, 29 Jun 2026 01:00:18 +0200 Subject: [PATCH] server pg backup --- client | 2 +- common/build.rs | 2 + common/proto/backup.proto | 67 +++ common/src/lib.rs | 3 + common/src/proto/descriptor.bin | Bin 76527 -> 80187 bytes common/src/proto/komp_ac.backup.rs | 833 +++++++++++++++++++++++++++++ server | 2 +- 7 files changed, 907 insertions(+), 2 deletions(-) create mode 100644 common/proto/backup.proto create mode 100644 common/src/proto/komp_ac.backup.rs 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 41dd8e3d1abb5d34116ce1b1f0f8223860d0fbd4..a98bac9cccfeb43178fe220e3eb791fd689c7a1c 100644 GIT binary patch delta 3609 zcmb7GO-~zF6rFkVf&Fa2Jd8aywgE#Fk^pHOh3_^v#t;JnYMV;!qLvFzVj*nTHdV8l zN|n0ori(256WU!D{RQp5tNw^e{Q*_a`ZeQcX)=7;zPM<&WHkFRWtD!t+kYk~<;Itnjb5K^ z(2&fo^qWDB zQSUd~Eg>5$-*}eo`P^!~`?B#qTsB2ReOIugZ35fDGDUk3;x<`~+7da2h$)o)h$eO$ z{i9B!E1Y2>{mY(bdxnPFUZmDMQ?^6?v(j1icS7TG8m=#b5p>$EUW2`x&mK|pyxBT) zxZ{yrdT`Lb=01|jB9*OByC-alRz`ADlH~e}Uh-M09hJ`2m_uZ|&`#2WI2{gdNb_0!{G z?c}g>Tr8A!O2zGn#-cQGJ-Bmna1hZ4pKh0Sb|Pf(X~{h-lq1IdZ*)5BkCiWjWoYu~ zxLD3tOGk&b{nFv~K+y!97>G*`sO-?_K&bG%SlCDPB#jM3+;Xu}Jt`OB;d`Bq`X1zJ z*)&aE5h~Su^`tW3BSoEC8Re71!_wg{tla2A@hc~VLb14w(GfQ3()ca~Rpa#h%|BDR zv-bbwYur6Lj2HdtYzex1%imRkU-cDbx336xZ_xGaoOd_q%3H@T^*J5J@2mTh%?(z$ z5q@`px9V5L)#$#pfQ-LyfxYiWsm)AHd#2L>)x*rtG{%1sX6Ra+1}QN#W*AzGQc7&i zWu~QtbpXTGbY@tA2^ylNtr29|-cvk_86m;rGz+wlPqRP^`7{f(5NH^(r7?3v z8y7RS_#j8DQ7&ik8N0?P$#9DtAvQ`99)jLzDy=dRijcSp@v-7&@DLIs6ET$tFy<%n zIga^>gvb0u7-S^wDiJ<9=4TqnWXR<1b!JXzN$H*!p0JoGrSlUKBlyC?JODy5fc~xhIa0I5#YY!4YcB$zkA>n|HN)QjYg=H;|$(4x%YmIWN270H=JO1caVk z?0j&-L(rRd62cya`#^gr^?17vpvUFJa2J#u0OS^woSgK6k^|a<-U9R_4h;_xG-uk^O5#g8s*b|6qpfAgP($& zG75l#IaLq{i8*By2y!{qx5>;W+J{n(UmZ^Z`1gyxP4PZ2D?K3SEh{}BWG*W`Am}Zt zzD+*771cKY*11AtA3!`7k$nS!wxasRh?udeP5}UDtHc#|G~WSutN5S84+Ri-t2hSI zCcqkz8#RdmmutRDKAyFpxUoSqc;>ixWq@#Lt`pCR3EH|(<6~G4!m}&N@k?_Z!5^ZX8`)V!LqD5Dd@Vq;LE9uA%?52VFs*1dXq&ThV%4t2 z%%>VYe)yo7T>YtfXDq(!Eh4@tCIIxdh%FR=khnE8;vwj5jfq &'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