From a2899ba5a25794aec60a093695675ff24f967484 Mon Sep 17 00:00:00 2001 From: Noor Date: Thu, 30 Jan 2025 18:23:29 +0530 Subject: [PATCH] Update proto messages and Rust types for brain integration removed uuid type and change it a simple string improved some grpc response type fix some typos --- proto/daemon.proto | 11 ++++++----- proto/shared.proto | 14 ++++---------- src/types/shared.rs | 31 +++++++++---------------------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/proto/daemon.proto b/proto/daemon.proto index 1ab3b1d..8bb2a66 100644 --- a/proto/daemon.proto +++ b/proto/daemon.proto @@ -6,10 +6,11 @@ import "shared.proto"; message NewContainerRes { - optional shared.UUID container_id = 1; + string uuid = 1; string status = 2; string ip_address = 3; repeated shared.MappedPort mapped_ports = 4; + string error = 5; } message ContainerInspectResp { @@ -30,7 +31,7 @@ message LogResp { message ContainerFilters { string admin_pubkey = 1; - optional shared.UUID container_id = 2; + optional string container_id = 2; } message ContainerListResp { @@ -38,7 +39,7 @@ message ContainerListResp { } message DeleteContainerRes { - optional shared.UUID container_id = 1; + optional string container_id = 1; string status = 2; } @@ -55,8 +56,8 @@ message BrainMessage { message DaemonMessage { oneof Msg { shared.Pubkey pubkey = 1; - NewContainerRes new_vm_resp = 2; - DeleteContainerRes delete_vm_resp = 3; + NewContainerRes new_container_resp = 2; + DeleteContainerRes delete_container_resp = 3; } } diff --git a/proto/shared.proto b/proto/shared.proto index cb603f6..85e9d76 100644 --- a/proto/shared.proto +++ b/proto/shared.proto @@ -8,11 +8,7 @@ message SetConfigResponse { message Empty { } -message UUID { - string uuid = 1; -} -// The main Config structure message ManagerConfigPB { repeated FileEntry filesystems = 1; repeated EnvironmentEntry environments = 2; @@ -20,13 +16,11 @@ message ManagerConfigPB { Container container = 4; } -// Represents a file entry with a path and content message FileEntry { string path = 1; string content = 2; } -// Represents an environment variable entry message EnvironmentEntry { string name = 1; string value = 2; @@ -41,7 +35,6 @@ message RestartPolicy { } } -// Represents a child process configuration message ChildProcess { string path = 1; repeated string arguments = 2; @@ -69,13 +62,14 @@ message ContainerContracts { message Container { - optional string package_url = 1; - string node = 2; + string package_url = 1; + string node_pubkey = 2; Resource resource = 3; - UUID uuid = 4; + string uuid = 4; string admin_pubkey = 5; } + message Resource { uint32 memory_mb = 1; uint32 disk_mb = 2; diff --git a/src/types/shared.rs b/src/types/shared.rs index 6116dd7..cb52c72 100644 --- a/src/types/shared.rs +++ b/src/types/shared.rs @@ -193,22 +193,23 @@ impl From for pb_shared::RestartPolicy { #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct Container { - pub package_url: Option, - pub node: String, + pub package_url: String, pub resource: Option, - pub uuid: Option, + #[serde(default)] + pub uuid: String, #[serde(default)] pub admin_pubkey: String, + pub node_pubkey: String, } impl From for Container { fn from(pb_val: pb_shared::Container) -> Self { Self { package_url: pb_val.package_url, - node: pb_val.node, resource: pb_val.resource.map(Resource::from), - uuid: pb_val.uuid.map(Uuid::from), + uuid: pb_val.uuid, admin_pubkey: pb_val.admin_pubkey, + node_pubkey: pb_val.node_pubkey, } } } @@ -217,29 +218,15 @@ impl From for pb_shared::Container { fn from(val: Container) -> pb_shared::Container { pb_shared::Container { package_url: val.package_url, - node: val.node, resource: val.resource.map(Into::into), - uuid: val.uuid.map(Into::into), + // uuid: val.uuid.map(Into::into), + uuid: val.uuid, admin_pubkey: val.admin_pubkey, + node_pubkey: val.node_pubkey, } } } -#[derive(Debug, Clone, Serialize, Deserialize, Default)] -pub struct Uuid { - pub uuid: String, -} - -impl From for Uuid { - fn from(pb_val: pb_shared::Uuid) -> Self { - Self { uuid: pb_val.uuid } - } -} -impl From for pb_shared::Uuid { - fn from(val: Uuid) -> pb_shared::Uuid { - pb_shared::Uuid { uuid: val.uuid } - } -} #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] pub struct Resource { pub memory_mb: u32,