surreal_brain_app #3

Merged
ghe0 merged 4 commits from surreal_brain_app into surreal_brain 2025-05-19 21:14:43 +00:00
5 changed files with 17 additions and 24 deletions

@ -7,11 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".vm_proto.MappedPort",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".app_proto.MappedPort",
".common_proto.MappedPort",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(

@ -11,7 +11,7 @@ message AppContract {
string node_pubkey = 4;
string public_ipv4 = 5;
AppResource resource = 6;
repeated MappedPort mapped_ports = 7;
repeated common_proto.MappedPort mapped_ports = 7;
string created_at = 8;
string updated_at = 9;
uint64 nano_per_minute = 10;
@ -44,16 +44,11 @@ message AppResource {
message NewAppRes {
string uuid = 1;
string status = 2;
string ip_address = 3;
repeated MappedPort mapped_ports = 4;
string error = 5;
string ip_address = 2;
repeated common_proto.MappedPort mapped_ports = 3;
string error = 4;
}
message MappedPort {
uint32 host_port = 1;
uint32 app_port = 2;
}
message DelAppReq {
string uuid= 1;
@ -76,6 +71,7 @@ message AppNodeFilters {
string city = 6;
string ip = 7;
string node_pubkey = 8;
uint32 free_ports = 9;
}
message AppNodeListResp {
@ -90,7 +86,7 @@ message AppNodeListResp {
}
service BrainAppCli {
rpc DeployApp (NewAppReq) returns (NewAppRes);
rpc NewApp (NewAppReq) returns (NewAppRes);
rpc DeleteApp (DelAppReq) returns (common_proto.Empty);
rpc ListAppContracts (ListAppContractsReq) returns (stream AppContract);
rpc ListAppNodes (AppNodeFilters) returns (stream AppNodeListResp);

@ -7,3 +7,8 @@ message Empty {
message Pubkey {
string pubkey = 1;
}
message MappedPort {
uint32 host_port = 1;
uint32 guest_port = 2;
}

@ -3,11 +3,6 @@ package vm_proto;
import "shared/common.proto";
message MappedPort {
uint32 host_port = 1;
uint32 guest_port = 2;
}
message VmContract {
string uuid = 1;
string hostname = 2;
@ -15,7 +10,7 @@ message VmContract {
string node_pubkey = 4;
string node_ip = 5;
string location = 6;
repeated MappedPort mapped_ports = 7;
repeated common_proto.MappedPort mapped_ports = 7;
string vm_public_ipv4 = 8;
string vm_public_ipv6 = 9;
uint32 disk_size_gb = 10;

@ -1,5 +1,6 @@
use crate::app_proto::{daemon_message_app, AppNodeResources, DaemonMessageApp};
use crate::app_proto::{AppResource, DaemonAuth, MappedPort, NewAppReq, NewAppRes};
use crate::app_proto::{AppResource, DaemonAuth, NewAppReq, NewAppRes};
use crate::common_proto::MappedPort;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
@ -93,14 +94,14 @@ impl From<(u16, u16)> for MappedPort {
fn from(val: (u16, u16)) -> Self {
Self {
host_port: val.0 as u32,
app_port: val.1 as u32,
guest_port: val.1 as u32,
}
}
}
impl From<MappedPort> for (u16, u16) {
fn from(val: MappedPort) -> Self {
(val.host_port as u16, val.app_port as u16)
(val.host_port as u16, val.guest_port as u16)
}
}