Refactor proto packages and add shared common.proto
seperated non vm related services into general protofile shared common proto for types like Empty rename proto packages top level crate export for convenient imports
This commit is contained in:
parent
be4e41db05
commit
e434b70a57
6
build.rs
6
build.rs
@ -20,11 +20,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
)
|
)
|
||||||
.compile_protos(
|
.compile_protos(
|
||||||
&[
|
&[
|
||||||
"proto/sgx/brain.proto",
|
"proto/sgx/app.proto",
|
||||||
"proto/sgx/dtpm.proto",
|
"proto/sgx/dtpm.proto",
|
||||||
"proto/snp/vm.proto",
|
"proto/snp/vm.proto",
|
||||||
|
"proto/shared/common.proto",
|
||||||
|
"proto/shared/general.proto",
|
||||||
],
|
],
|
||||||
&["proto/sgx", "proto/snp"],
|
&["proto"],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package brain;
|
package app_proto;
|
||||||
|
|
||||||
message Empty {
|
import "shared/common.proto";
|
||||||
}
|
|
||||||
|
|
||||||
message AppContract {
|
message AppContract {
|
||||||
string uuid = 1;
|
string uuid = 1;
|
||||||
@ -92,13 +91,13 @@ message AppNodeListResp {
|
|||||||
|
|
||||||
service BrainAppCli {
|
service BrainAppCli {
|
||||||
rpc DeployApp (NewAppReq) returns (NewAppRes);
|
rpc DeployApp (NewAppReq) returns (NewAppRes);
|
||||||
rpc DeleteApp (DelAppReq) returns (Empty);
|
rpc DeleteApp (DelAppReq) returns (common_proto.Empty);
|
||||||
rpc ListAppContracts (ListAppContractsReq) returns (stream AppContract);
|
rpc ListAppContracts (ListAppContractsReq) returns (stream AppContract);
|
||||||
rpc ListAppNodes (AppNodeFilters) returns (stream AppNodeListResp);
|
rpc ListAppNodes (AppNodeFilters) returns (stream AppNodeListResp);
|
||||||
rpc GetOneAppNode (AppNodeFilters) returns (AppNodeListResp);
|
rpc GetOneAppNode (AppNodeFilters) returns (AppNodeListResp);
|
||||||
|
|
||||||
// super admin commands
|
// super admin commands
|
||||||
rpc ListAllAppContracts (Empty) returns (stream AppContract);
|
// rpc ListAllAppContracts (common_proto.Empty) returns (stream AppContract);
|
||||||
}
|
}
|
||||||
|
|
||||||
message RegisterAppNodeReq {
|
message RegisterAppNodeReq {
|
||||||
@ -145,5 +144,5 @@ message DaemonMessageApp {
|
|||||||
service BrainAppDaemon {
|
service BrainAppDaemon {
|
||||||
rpc RegisterAppNode (RegisterAppNodeReq) returns (stream AppContract);
|
rpc RegisterAppNode (RegisterAppNodeReq) returns (stream AppContract);
|
||||||
rpc BrainMessages (DaemonAuth) returns (stream BrainMessageApp);
|
rpc BrainMessages (DaemonAuth) returns (stream BrainMessageApp);
|
||||||
rpc DaemonMessages (stream DaemonMessageApp) returns (Empty);
|
rpc DaemonMessages (stream DaemonMessageApp) returns (common_proto.Empty);
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package dtpm;
|
package dtpm_proto;
|
||||||
|
|
||||||
message Empty {
|
message Empty {
|
||||||
}
|
}
|
||||||
|
9
proto/shared/common.proto
Normal file
9
proto/shared/common.proto
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package common_proto;
|
||||||
|
|
||||||
|
message Empty {
|
||||||
|
}
|
||||||
|
|
||||||
|
message Pubkey {
|
||||||
|
string pubkey = 1;
|
||||||
|
}
|
91
proto/shared/general.proto
Normal file
91
proto/shared/general.proto
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package general_proto;
|
||||||
|
|
||||||
|
import "sgx/app.proto";
|
||||||
|
import "shared/common.proto";
|
||||||
|
import "snp/vm.proto";
|
||||||
|
|
||||||
|
message AccountBalance {
|
||||||
|
uint64 balance = 1;
|
||||||
|
uint64 tmp_locked = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReportNodeReq {
|
||||||
|
string admin_pubkey = 1;
|
||||||
|
string node_pubkey = 2;
|
||||||
|
string contract = 3;
|
||||||
|
string reason = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ListOperatorsResp {
|
||||||
|
string pubkey = 1;
|
||||||
|
uint64 escrow = 2;
|
||||||
|
string email = 3;
|
||||||
|
uint64 app_nodes = 4;
|
||||||
|
uint64 vm_nodes = 5;
|
||||||
|
uint64 reports = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message InspectOperatorResp {
|
||||||
|
ListOperatorsResp operator = 1;
|
||||||
|
repeated vm_proto.VmNodeListResp vm_nodes = 2;
|
||||||
|
repeated app_proto.AppNodeListResp app_nodes = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RegOperatorReq {
|
||||||
|
string pubkey = 1;
|
||||||
|
uint64 escrow = 2;
|
||||||
|
string email = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message KickReq {
|
||||||
|
string operator_wallet = 1;
|
||||||
|
string contract_uuid = 2;
|
||||||
|
string reason = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message KickResp {
|
||||||
|
uint64 nano_lp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BanUserReq {
|
||||||
|
string operator_wallet = 1;
|
||||||
|
string user_wallet = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AirdropReq {
|
||||||
|
string pubkey = 1;
|
||||||
|
uint64 tokens = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SlashReq {
|
||||||
|
string pubkey = 1;
|
||||||
|
uint64 tokens = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Account {
|
||||||
|
string pubkey = 1;
|
||||||
|
uint64 balance = 2;
|
||||||
|
uint64 tmp_locked = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
service BrainGeneralCli {
|
||||||
|
rpc GetBalance (common_proto.Pubkey) returns (AccountBalance);
|
||||||
|
|
||||||
|
rpc ReportNode (ReportNodeReq) returns (common_proto.Empty);
|
||||||
|
rpc ListOperators (common_proto.Empty) returns (stream ListOperatorsResp);
|
||||||
|
rpc InspectOperator (common_proto.Pubkey) returns (InspectOperatorResp);
|
||||||
|
rpc RegisterOperator (RegOperatorReq) returns (common_proto.Empty);
|
||||||
|
rpc KickContract (KickReq) returns (KickResp);
|
||||||
|
rpc BanUser (BanUserReq) returns (common_proto.Empty);
|
||||||
|
|
||||||
|
// admin commands
|
||||||
|
rpc Airdrop (AirdropReq) returns (common_proto.Empty);
|
||||||
|
rpc Slash (SlashReq) returns (common_proto.Empty);
|
||||||
|
rpc ListAccounts (common_proto.Empty) returns (stream Account);
|
||||||
|
rpc ListAllVmContracts (common_proto.Empty)
|
||||||
|
returns (stream vm_proto.VmContract);
|
||||||
|
rpc ListAllAppContracts (common_proto.Empty)
|
||||||
|
returns (stream app_proto.AppContract);
|
||||||
|
}
|
@ -1,17 +1,7 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package vm_proto;
|
package vm_proto;
|
||||||
|
|
||||||
message Empty {
|
import "shared/common.proto";
|
||||||
}
|
|
||||||
|
|
||||||
message Pubkey {
|
|
||||||
string pubkey = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AccountBalance {
|
|
||||||
uint64 balance = 1;
|
|
||||||
uint64 tmp_locked = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message VmContract {
|
message VmContract {
|
||||||
string uuid = 1;
|
string uuid = 1;
|
||||||
@ -150,7 +140,7 @@ message VmDaemonMessage {
|
|||||||
service BrainVmDaemon {
|
service BrainVmDaemon {
|
||||||
rpc RegisterVmNode (RegisterVmNodeReq) returns (stream VmContract);
|
rpc RegisterVmNode (RegisterVmNodeReq) returns (stream VmContract);
|
||||||
rpc BrainMessages (DaemonStreamAuth) returns (stream BrainVmMessage);
|
rpc BrainMessages (DaemonStreamAuth) returns (stream BrainVmMessage);
|
||||||
rpc DaemonMessages (stream VmDaemonMessage) returns (Empty);
|
rpc DaemonMessages (stream VmDaemonMessage) returns (common_proto.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListVmContractsReq {
|
message ListVmContractsReq {
|
||||||
@ -190,82 +180,12 @@ message ExtendVmReq {
|
|||||||
uint64 locked_nano = 3;
|
uint64 locked_nano = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AirdropReq {
|
service BrainVmCli {
|
||||||
string pubkey = 1;
|
|
||||||
uint64 tokens = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message SlashReq {
|
|
||||||
string pubkey = 1;
|
|
||||||
uint64 tokens = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Account {
|
|
||||||
string pubkey = 1;
|
|
||||||
uint64 balance = 2;
|
|
||||||
uint64 tmp_locked = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RegOperatorReq {
|
|
||||||
string pubkey = 1;
|
|
||||||
uint64 escrow = 2;
|
|
||||||
string email = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListOperatorsResp {
|
|
||||||
string pubkey = 1;
|
|
||||||
uint64 escrow = 2;
|
|
||||||
string email = 3;
|
|
||||||
uint64 app_nodes = 4;
|
|
||||||
uint64 vm_nodes = 5;
|
|
||||||
uint64 reports = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
message InspectOperatorResp {
|
|
||||||
ListOperatorsResp operator = 1;
|
|
||||||
repeated VmNodeListResp nodes = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ReportNodeReq {
|
|
||||||
string admin_pubkey = 1;
|
|
||||||
string node_pubkey = 2;
|
|
||||||
string contract = 3;
|
|
||||||
string reason = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message KickReq {
|
|
||||||
string operator_wallet = 1;
|
|
||||||
string contract_uuid = 2;
|
|
||||||
string reason = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message BanUserReq {
|
|
||||||
string operator_wallet = 1;
|
|
||||||
string user_wallet = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message KickResp {
|
|
||||||
uint64 nano_lp = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
service BrainCli {
|
|
||||||
rpc GetBalance (Pubkey) returns (AccountBalance);
|
|
||||||
rpc NewVm (NewVmReq) returns (NewVmResp);
|
rpc NewVm (NewVmReq) returns (NewVmResp);
|
||||||
rpc ListVmContracts (ListVmContractsReq) returns (stream VmContract);
|
rpc ListVmContracts (ListVmContractsReq) returns (stream VmContract);
|
||||||
rpc ListVmNodes (VmNodeFilters) returns (stream VmNodeListResp);
|
rpc ListVmNodes (VmNodeFilters) returns (stream VmNodeListResp);
|
||||||
rpc GetOneVmNode (VmNodeFilters) returns (VmNodeListResp);
|
rpc GetOneVmNode (VmNodeFilters) returns (VmNodeListResp);
|
||||||
rpc DeleteVm (DeleteVmReq) returns (Empty);
|
rpc DeleteVm (DeleteVmReq) returns (common_proto.Empty);
|
||||||
rpc UpdateVm (UpdateVmReq) returns (UpdateVmResp);
|
rpc UpdateVm (UpdateVmReq) returns (UpdateVmResp);
|
||||||
rpc ExtendVm (ExtendVmReq) returns (Empty);
|
rpc ExtendVm (ExtendVmReq) returns (common_proto.Empty);
|
||||||
rpc ReportNode (ReportNodeReq) returns (Empty);
|
|
||||||
rpc ListOperators (Empty) returns (stream ListOperatorsResp);
|
|
||||||
rpc InspectOperator (Pubkey) returns (InspectOperatorResp);
|
|
||||||
rpc RegisterOperator (RegOperatorReq) returns (Empty);
|
|
||||||
rpc KickContract (KickReq) returns (KickResp);
|
|
||||||
rpc BanUser (BanUserReq) returns (Empty);
|
|
||||||
// admin commands
|
|
||||||
rpc Airdrop (AirdropReq) returns (Empty);
|
|
||||||
rpc Slash (SlashReq) returns (Empty);
|
|
||||||
rpc ListAllVmContracts (Empty) returns (stream VmContract);
|
|
||||||
rpc ListAccounts (Empty) returns (stream Account);
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
pub mod sgx;
|
pub mod sgx;
|
||||||
|
pub mod shared;
|
||||||
pub mod snp;
|
pub mod snp;
|
||||||
|
|
||||||
|
pub use sgx::pb::app_proto;
|
||||||
|
pub use shared::pb::{common_proto, general_proto};
|
||||||
|
pub use snp::pb::vm_proto;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub mod pb {
|
pub mod pb {
|
||||||
|
pub mod app_proto {
|
||||||
pub mod brain {
|
tonic::include_proto!("app_proto");
|
||||||
tonic::include_proto!("brain");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod dtpm {
|
pub mod dtpm_proto {
|
||||||
tonic::include_proto!("dtpm");
|
tonic::include_proto!("dtpm_proto");
|
||||||
}
|
}
|
||||||
|
use crate::common_proto;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::sgx::pb::brain::{daemon_message_app, AppNodeResources, DaemonMessageApp, NewAppRes};
|
use crate::app_proto::{daemon_message_app, AppNodeResources, DaemonMessageApp};
|
||||||
use crate::sgx::pb::brain::{AppResource, DaemonAuth, MappedPort, NewAppReq};
|
use crate::app_proto::{AppResource, DaemonAuth, MappedPort, NewAppReq, NewAppRes};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::sgx::pb::dtpm as pb_dtpm;
|
use crate::sgx::pb::dtpm_proto;
|
||||||
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
|
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -9,8 +9,8 @@ pub struct DtpmConfig {
|
|||||||
pub child_processes: Vec<ChildProcess>,
|
pub child_processes: Vec<ChildProcess>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<pb_dtpm::DtpmConfigData> for DtpmConfig {
|
impl From<dtpm_proto::DtpmConfigData> for DtpmConfig {
|
||||||
fn from(pb_val: pb_dtpm::DtpmConfigData) -> Self {
|
fn from(pb_val: dtpm_proto::DtpmConfigData) -> Self {
|
||||||
DtpmConfig {
|
DtpmConfig {
|
||||||
filesystems: pb_val
|
filesystems: pb_val
|
||||||
.filesystems
|
.filesystems
|
||||||
@ -31,9 +31,9 @@ impl From<pb_dtpm::DtpmConfigData> for DtpmConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DtpmConfig> for pb_dtpm::DtpmConfigData {
|
impl From<DtpmConfig> for dtpm_proto::DtpmConfigData {
|
||||||
fn from(val: DtpmConfig) -> pb_dtpm::DtpmConfigData {
|
fn from(val: DtpmConfig) -> dtpm_proto::DtpmConfigData {
|
||||||
pb_dtpm::DtpmConfigData {
|
dtpm_proto::DtpmConfigData {
|
||||||
filesystems: val.filesystems.into_iter().map(Into::into).collect(),
|
filesystems: val.filesystems.into_iter().map(Into::into).collect(),
|
||||||
environments: val.environments.into_iter().map(Into::into).collect(),
|
environments: val.environments.into_iter().map(Into::into).collect(),
|
||||||
child_processes: val.child_processes.into_iter().map(Into::into).collect(),
|
child_processes: val.child_processes.into_iter().map(Into::into).collect(),
|
||||||
@ -47,17 +47,17 @@ pub struct FileEntry {
|
|||||||
pub content: FileContent,
|
pub content: FileContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<pb_dtpm::FileEntry> for FileEntry {
|
impl From<dtpm_proto::FileEntry> for FileEntry {
|
||||||
fn from(pb_val: pb_dtpm::FileEntry) -> Self {
|
fn from(pb_val: dtpm_proto::FileEntry) -> Self {
|
||||||
FileEntry {
|
FileEntry {
|
||||||
path: pb_val.path,
|
path: pb_val.path,
|
||||||
content: FileContent::Data(pb_val.content),
|
content: FileContent::Data(pb_val.content),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<FileEntry> for pb_dtpm::FileEntry {
|
impl From<FileEntry> for dtpm_proto::FileEntry {
|
||||||
fn from(val: FileEntry) -> pb_dtpm::FileEntry {
|
fn from(val: FileEntry) -> dtpm_proto::FileEntry {
|
||||||
pb_dtpm::FileEntry {
|
dtpm_proto::FileEntry {
|
||||||
path: val.path,
|
path: val.path,
|
||||||
content: match val.content {
|
content: match val.content {
|
||||||
FileContent::Data(data) => data,
|
FileContent::Data(data) => data,
|
||||||
@ -81,8 +81,8 @@ pub struct EnvironmentEntry {
|
|||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<pb_dtpm::EnvironmentEntry> for EnvironmentEntry {
|
impl From<dtpm_proto::EnvironmentEntry> for EnvironmentEntry {
|
||||||
fn from(pb_val: pb_dtpm::EnvironmentEntry) -> Self {
|
fn from(pb_val: dtpm_proto::EnvironmentEntry) -> Self {
|
||||||
EnvironmentEntry {
|
EnvironmentEntry {
|
||||||
name: pb_val.name,
|
name: pb_val.name,
|
||||||
value: pb_val.value,
|
value: pb_val.value,
|
||||||
@ -90,9 +90,9 @@ impl From<pb_dtpm::EnvironmentEntry> for EnvironmentEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EnvironmentEntry> for pb_dtpm::EnvironmentEntry {
|
impl From<EnvironmentEntry> for dtpm_proto::EnvironmentEntry {
|
||||||
fn from(val: EnvironmentEntry) -> pb_dtpm::EnvironmentEntry {
|
fn from(val: EnvironmentEntry) -> dtpm_proto::EnvironmentEntry {
|
||||||
pb_dtpm::EnvironmentEntry {
|
dtpm_proto::EnvironmentEntry {
|
||||||
name: val.name,
|
name: val.name,
|
||||||
value: val.value,
|
value: val.value,
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ pub struct ChildProcess {
|
|||||||
pub restart: Option<RestartPolicy>,
|
pub restart: Option<RestartPolicy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<pb_dtpm::ChildProcess> for ChildProcess {
|
impl From<dtpm_proto::ChildProcess> for ChildProcess {
|
||||||
fn from(pb_val: pb_dtpm::ChildProcess) -> Self {
|
fn from(pb_val: dtpm_proto::ChildProcess) -> Self {
|
||||||
ChildProcess {
|
ChildProcess {
|
||||||
path: pb_val.path,
|
path: pb_val.path,
|
||||||
arguments: pb_val.arguments,
|
arguments: pb_val.arguments,
|
||||||
@ -116,9 +116,9 @@ impl From<pb_dtpm::ChildProcess> for ChildProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ChildProcess> for pb_dtpm::ChildProcess {
|
impl From<ChildProcess> for dtpm_proto::ChildProcess {
|
||||||
fn from(val: ChildProcess) -> pb_dtpm::ChildProcess {
|
fn from(val: ChildProcess) -> dtpm_proto::ChildProcess {
|
||||||
pb_dtpm::ChildProcess {
|
dtpm_proto::ChildProcess {
|
||||||
path: val.path,
|
path: val.path,
|
||||||
arguments: val.arguments,
|
arguments: val.arguments,
|
||||||
restart: val.restart.map(Into::into),
|
restart: val.restart.map(Into::into),
|
||||||
@ -144,16 +144,16 @@ impl Default for RestartPolicyType {
|
|||||||
RestartPolicyType::Always(true)
|
RestartPolicyType::Always(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<pb_dtpm::RestartPolicy> for RestartPolicy {
|
impl From<dtpm_proto::RestartPolicy> for RestartPolicy {
|
||||||
fn from(pb_val: pb_dtpm::RestartPolicy) -> Self {
|
fn from(pb_val: dtpm_proto::RestartPolicy) -> Self {
|
||||||
RestartPolicy {
|
RestartPolicy {
|
||||||
max_retries: pb_val.max_retries,
|
max_retries: pb_val.max_retries,
|
||||||
delay_seconds: pb_val.delay_seconds,
|
delay_seconds: pb_val.delay_seconds,
|
||||||
policy: match pb_val.policy_type {
|
policy: match pb_val.policy_type {
|
||||||
Some(pb_dtpm::restart_policy::PolicyType::Always(_)) => {
|
Some(dtpm_proto::restart_policy::PolicyType::Always(_)) => {
|
||||||
Some(RestartPolicyType::Always(true))
|
Some(RestartPolicyType::Always(true))
|
||||||
}
|
}
|
||||||
Some(pb_dtpm::restart_policy::PolicyType::OnNonZeroExit(_)) => {
|
Some(dtpm_proto::restart_policy::PolicyType::OnNonZeroExit(_)) => {
|
||||||
Some(RestartPolicyType::OnNonZeroExit(true))
|
Some(RestartPolicyType::OnNonZeroExit(true))
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
@ -162,17 +162,17 @@ impl From<pb_dtpm::RestartPolicy> for RestartPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RestartPolicy> for pb_dtpm::RestartPolicy {
|
impl From<RestartPolicy> for dtpm_proto::RestartPolicy {
|
||||||
fn from(val: RestartPolicy) -> pb_dtpm::RestartPolicy {
|
fn from(val: RestartPolicy) -> dtpm_proto::RestartPolicy {
|
||||||
pb_dtpm::RestartPolicy {
|
dtpm_proto::RestartPolicy {
|
||||||
max_retries: val.max_retries,
|
max_retries: val.max_retries,
|
||||||
delay_seconds: val.delay_seconds,
|
delay_seconds: val.delay_seconds,
|
||||||
policy_type: match val.policy {
|
policy_type: match val.policy {
|
||||||
Some(RestartPolicyType::Always(_)) => {
|
Some(RestartPolicyType::Always(_)) => {
|
||||||
Some(pb_dtpm::restart_policy::PolicyType::Always(true))
|
Some(dtpm_proto::restart_policy::PolicyType::Always(true))
|
||||||
}
|
}
|
||||||
Some(RestartPolicyType::OnNonZeroExit(_)) => {
|
Some(RestartPolicyType::OnNonZeroExit(_)) => {
|
||||||
Some(pb_dtpm::restart_policy::PolicyType::OnNonZeroExit(true))
|
Some(dtpm_proto::restart_policy::PolicyType::OnNonZeroExit(true))
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
|
12
src/shared/mod.rs
Normal file
12
src/shared/mod.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pub mod pb {
|
||||||
|
pub mod general_proto {
|
||||||
|
tonic::include_proto!("general_proto");
|
||||||
|
}
|
||||||
|
pub mod common_proto {
|
||||||
|
tonic::include_proto!("common_proto");
|
||||||
|
}
|
||||||
|
|
||||||
|
// For compiling proto
|
||||||
|
use crate::app_proto;
|
||||||
|
use crate::vm_proto;
|
||||||
|
}
|
@ -1,11 +1,12 @@
|
|||||||
pub mod pb {
|
pub mod pb {
|
||||||
|
pub mod vm_proto {
|
||||||
pub mod vm {
|
|
||||||
tonic::include_proto!("vm_proto");
|
tonic::include_proto!("vm_proto");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use crate::common_proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
use pb::vm as snp_proto;
|
use pb::vm_proto as snp_proto;
|
||||||
|
|
||||||
impl From<snp_proto::NewVmResp> for snp_proto::VmDaemonMessage {
|
impl From<snp_proto::NewVmResp> for snp_proto::VmDaemonMessage {
|
||||||
fn from(value: snp_proto::NewVmResp) -> Self {
|
fn from(value: snp_proto::NewVmResp) -> Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user