pgdump from rust for superadmin
This commit is contained in:
@@ -6,6 +6,7 @@ import "common.proto";
|
||||
service BackupService {
|
||||
rpc StartBackup(StartBackupRequest) returns (BackupOperationResponse);
|
||||
rpc StartCheck(komp_ac.common.Empty) returns (BackupOperationResponse);
|
||||
rpc StartDump(komp_ac.common.Empty) returns (BackupOperationResponse);
|
||||
rpc GetBackupInfo(komp_ac.common.Empty) returns (BackupInfoResponse);
|
||||
rpc GetOperationStatus(GetOperationStatusRequest) returns (BackupOperationResponse);
|
||||
}
|
||||
@@ -21,6 +22,7 @@ enum OperationKind {
|
||||
OPERATION_KIND_UNSPECIFIED = 0;
|
||||
OPERATION_KIND_BACKUP = 1;
|
||||
OPERATION_KIND_CHECK = 2;
|
||||
OPERATION_KIND_DUMP = 3;
|
||||
}
|
||||
|
||||
enum OperationStatus {
|
||||
|
||||
Binary file not shown.
@@ -71,6 +71,7 @@ pub enum OperationKind {
|
||||
Unspecified = 0,
|
||||
Backup = 1,
|
||||
Check = 2,
|
||||
Dump = 3,
|
||||
}
|
||||
impl OperationKind {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
@@ -82,6 +83,7 @@ impl OperationKind {
|
||||
Self::Unspecified => "OPERATION_KIND_UNSPECIFIED",
|
||||
Self::Backup => "OPERATION_KIND_BACKUP",
|
||||
Self::Check => "OPERATION_KIND_CHECK",
|
||||
Self::Dump => "OPERATION_KIND_DUMP",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
@@ -90,6 +92,7 @@ impl OperationKind {
|
||||
"OPERATION_KIND_UNSPECIFIED" => Some(Self::Unspecified),
|
||||
"OPERATION_KIND_BACKUP" => Some(Self::Backup),
|
||||
"OPERATION_KIND_CHECK" => Some(Self::Check),
|
||||
"OPERATION_KIND_DUMP" => Some(Self::Dump),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -265,6 +268,30 @@ pub mod backup_service_client {
|
||||
.insert(GrpcMethod::new("komp_ac.backup.BackupService", "StartCheck"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn start_dump(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::super::common::Empty>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::BackupOperationResponse>,
|
||||
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/StartDump",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(GrpcMethod::new("komp_ac.backup.BackupService", "StartDump"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn get_backup_info(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::super::common::Empty>,
|
||||
@@ -346,6 +373,13 @@ pub mod backup_service_server {
|
||||
tonic::Response<super::BackupOperationResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
async fn start_dump(
|
||||
&self,
|
||||
request: tonic::Request<super::super::common::Empty>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::BackupOperationResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
async fn get_backup_info(
|
||||
&self,
|
||||
request: tonic::Request<super::super::common::Empty>,
|
||||
@@ -527,6 +561,51 @@ pub mod backup_service_server {
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
"/komp_ac.backup.BackupService/StartDump" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct StartDumpSvc<T: BackupService>(pub Arc<T>);
|
||||
impl<
|
||||
T: BackupService,
|
||||
> tonic::server::UnaryService<super::super::common::Empty>
|
||||
for StartDumpSvc<T> {
|
||||
type Response = super::BackupOperationResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::super::common::Empty>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as BackupService>::start_dump(&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 = StartDumpSvc(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<T: BackupService>(pub Arc<T>);
|
||||
|
||||
Reference in New Issue
Block a user