diff --git a/client-gui2 b/client-gui2 index bdefd862..5c3181a6 160000 --- a/client-gui2 +++ b/client-gui2 @@ -1 +1 @@ -Subproject commit bdefd862ebf3a984b1621978e73e6576a3b34c86 +Subproject commit 5c3181a65d943639caab3182e723206da316eaef diff --git a/common/proto/backup.proto b/common/proto/backup.proto index 1589883a..65a189ed 100644 --- a/common/proto/backup.proto +++ b/common/proto/backup.proto @@ -9,6 +9,41 @@ service BackupService { rpc StartDump(komp_ac.common.Empty) returns (BackupOperationResponse); rpc GetBackupInfo(komp_ac.common.Empty) returns (BackupInfoResponse); rpc GetOperationStatus(GetOperationStatusRequest) returns (BackupOperationResponse); + rpc ListDatabases(komp_ac.common.Empty) returns (ListDatabasesResponse); + rpc CreateDatabase(CreateDatabaseRequest) returns (DatabaseInfo); + rpc RunDatabaseMigrations(DatabaseRequest) returns (DatabaseInfo); + rpc ActivateDatabase(DatabaseRequest) returns (ActivateDatabaseResponse); +} + +message DatabaseRequest { + string database_name = 1; +} + +message CreateDatabaseRequest { + string database_name = 1; +} + +message DatabaseInfo { + string database_name = 1; + bool active = 2; + bool connectable = 3; + int64 size_bytes = 4; + int32 applied_migrations = 5; + int32 pending_migrations = 6; + bool migration_dirty = 7; + bool application_database = 8; + string status = 9; +} + +message ListDatabasesResponse { + string mode = 1; + repeated DatabaseInfo databases = 2; +} + +message ActivateDatabaseResponse { + string database_name = 1; + bool switching = 2; + string message = 3; } enum BackupType { diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 6c695577..2bbd1451 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 index fe56a94f..e8885b81 100644 --- a/common/src/proto/komp_ac.backup.rs +++ b/common/src/proto/komp_ac.backup.rs @@ -1,4 +1,51 @@ // This file is @generated by prost-build. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct DatabaseRequest { + #[prost(string, tag = "1")] + pub database_name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CreateDatabaseRequest { + #[prost(string, tag = "1")] + pub database_name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct DatabaseInfo { + #[prost(string, tag = "1")] + pub database_name: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub active: bool, + #[prost(bool, tag = "3")] + pub connectable: bool, + #[prost(int64, tag = "4")] + pub size_bytes: i64, + #[prost(int32, tag = "5")] + pub applied_migrations: i32, + #[prost(int32, tag = "6")] + pub pending_migrations: i32, + #[prost(bool, tag = "7")] + pub migration_dirty: bool, + #[prost(bool, tag = "8")] + pub application_database: bool, + #[prost(string, tag = "9")] + pub status: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListDatabasesResponse { + #[prost(string, tag = "1")] + pub mode: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub databases: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ActivateDatabaseResponse { + #[prost(string, tag = "1")] + pub database_name: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub switching: bool, + #[prost(string, tag = "3")] + pub message: ::prost::alloc::string::String, +} #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct StartBackupRequest { #[prost(enumeration = "BackupType", tag = "1")] @@ -362,6 +409,107 @@ pub mod backup_service_client { ); self.inner.unary(req, path, codec).await } + pub async fn list_databases( + &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/ListDatabases", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "ListDatabases"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn create_database( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, 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/CreateDatabase", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "CreateDatabase"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn run_database_migrations( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, 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/RunDatabaseMigrations", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.backup.BackupService", + "RunDatabaseMigrations", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn activate_database( + &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/ActivateDatabase", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.backup.BackupService", "ActivateDatabase"), + ); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -412,6 +560,28 @@ pub mod backup_service_server { tonic::Response, tonic::Status, >; + async fn list_databases( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn create_database( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn run_database_migrations( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn activate_database( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct BackupServiceServer { @@ -715,6 +885,191 @@ pub mod backup_service_server { }; Box::pin(fut) } + "/komp_ac.backup.BackupService/ListDatabases" => { + #[allow(non_camel_case_types)] + struct ListDatabasesSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for ListDatabasesSvc { + type Response = super::ListDatabasesResponse; + 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 { + ::list_databases(&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 = ListDatabasesSvc(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/CreateDatabase" => { + #[allow(non_camel_case_types)] + struct CreateDatabaseSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for CreateDatabaseSvc { + type Response = super::DatabaseInfo; + 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 { + ::create_database(&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 = CreateDatabaseSvc(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/RunDatabaseMigrations" => { + #[allow(non_camel_case_types)] + struct RunDatabaseMigrationsSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for RunDatabaseMigrationsSvc { + type Response = super::DatabaseInfo; + 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 { + ::run_database_migrations( + &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 = RunDatabaseMigrationsSvc(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/ActivateDatabase" => { + #[allow(non_camel_case_types)] + struct ActivateDatabaseSvc(pub Arc); + impl< + T: BackupService, + > tonic::server::UnaryService + for ActivateDatabaseSvc { + type Response = super::ActivateDatabaseResponse; + 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 { + ::activate_database(&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 = ActivateDatabaseSvc(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( diff --git a/server b/server index 13424600..ec9f1f19 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 134246004802400453349934d3f6794ddf3e8654 +Subproject commit ec9f1f19de0b25286afdfc27205f4afd3d0ef2a6