Add proto for daemon
renamed to shared proto update build configuration changed exports for both protos in lib new rust structures for daemon types
This commit is contained in:
parent
e643da298f
commit
358c2d84ca
5
build.rs
5
build.rs
@ -1,5 +1,8 @@
|
|||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tonic_build::compile_protos("proto/manager_protobuf.proto")?;
|
tonic_build::configure()
|
||||||
|
.build_server(true)
|
||||||
|
.protoc_arg("--experimental_allow_proto3_optional")
|
||||||
|
.compile_protos(&["proto/daemon.proto", "proto/shared.proto"], &["proto"])?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
23
proto/daemon.proto
Normal file
23
proto/daemon.proto
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package deamon;
|
||||||
|
|
||||||
|
import "shared.proto";
|
||||||
|
|
||||||
|
message Empty {
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewContainerReq {
|
||||||
|
repeated string port = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewContainerRes {
|
||||||
|
string status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
service DaemonService {
|
||||||
|
// rpc CreateContainer (NewContainerReq) returns (NewContainerRes);
|
||||||
|
rpc CreateContainer (shared.Container) returns (NewContainerRes);
|
||||||
|
// rpc ListContainer (NodeFilters) returns (stream NodeListResp);
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package dtpm_proto;
|
package shared;
|
||||||
|
|
||||||
message SetConfigResponse {
|
message SetConfigResponse {
|
||||||
string status = 1;
|
string status = 1;
|
||||||
@ -13,6 +13,7 @@ message ManagerConfigPB {
|
|||||||
repeated FileEntry filesystem = 1;
|
repeated FileEntry filesystem = 1;
|
||||||
repeated EnvironmentEntry environment = 2;
|
repeated EnvironmentEntry environment = 2;
|
||||||
repeated ChildProcess child_processes = 3;
|
repeated ChildProcess child_processes = 3;
|
||||||
|
Container container = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents a file entry with a path and content
|
// Represents a file entry with a path and content
|
||||||
@ -49,4 +50,18 @@ message ChildProcess {
|
|||||||
service ConfigManager {
|
service ConfigManager {
|
||||||
rpc SetConfig(ManagerConfigPB) returns (SetConfigResponse) {}
|
rpc SetConfig(ManagerConfigPB) returns (SetConfigResponse) {}
|
||||||
rpc GetConfig(Empty) returns (ManagerConfigPB) {}
|
rpc GetConfig(Empty) returns (ManagerConfigPB) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message Container {
|
||||||
|
optional string package_url = 1;
|
||||||
|
string node = 2;
|
||||||
|
Resource resource = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Resource {
|
||||||
|
uint32 memory_mb = 1;
|
||||||
|
uint32 disk_mb = 2;
|
||||||
|
uint32 vcpu = 3;
|
||||||
|
repeated uint32 ports = 4;
|
||||||
|
}
|
31
src/lib.rs
31
src/lib.rs
@ -1,5 +1,10 @@
|
|||||||
pub mod pb {
|
pub mod pb {
|
||||||
tonic::include_proto!("dtpm_proto");
|
pub mod shared {
|
||||||
|
tonic::include_proto!("shared");
|
||||||
|
}
|
||||||
|
pub mod daemon {
|
||||||
|
tonic::include_proto!("deamon");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod config {
|
pub mod config {
|
||||||
@ -71,6 +76,28 @@ pub mod config {
|
|||||||
pub restart: Option<RestartPolicy>,
|
pub restart: Option<RestartPolicy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, prost::Message)]
|
||||||
|
pub struct Container {
|
||||||
|
#[prost(string, optional, tag = "1")]
|
||||||
|
pub package_url: Option<String>,
|
||||||
|
#[prost(string, tag = "2")]
|
||||||
|
pub node: String,
|
||||||
|
#[prost(message, optional, tag = "3")]
|
||||||
|
pub resource: Option<Resource>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, PartialEq, prost::Message)]
|
||||||
|
pub struct Resource {
|
||||||
|
#[prost(uint32, tag = "1")]
|
||||||
|
memory_mb: u32,
|
||||||
|
#[prost(uint32, tag = "2")]
|
||||||
|
disk_mb: u32,
|
||||||
|
#[prost(uint32, tag = "3")]
|
||||||
|
vcpu: u32,
|
||||||
|
#[prost(uint32, repeated, tag = "4")]
|
||||||
|
port: Vec<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, prost::Message)]
|
#[derive(Clone, Serialize, Deserialize, prost::Message)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[prost(message, repeated, tag = "1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
@ -79,6 +106,8 @@ pub mod config {
|
|||||||
pub environment: Vec<EnvironmentEntry>,
|
pub environment: Vec<EnvironmentEntry>,
|
||||||
#[prost(message, repeated, tag = "3")]
|
#[prost(message, repeated, tag = "3")]
|
||||||
pub child_processes: Vec<ChildProcess>,
|
pub child_processes: Vec<ChildProcess>,
|
||||||
|
#[prost(message, optional, tag = "4")]
|
||||||
|
pub container: Option<Container>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
Loading…
Reference in New Issue
Block a user