syntax = "proto3"; // 整体封装的消息体 message RequestFrame { uint32 packet_id = 1; oneof body { AuthRequest auth_request = 2; ContainerRequest container_request = 3; } } message ReplyFrame { uint32 packet_id = 1; oneof reply { ReplyResult result = 2; ReplyError error = 3; } } message ReplyResult { bytes data = 1; } message ReplyError { int32 code = 1; string message = 2; } message CastFrame { oneof body { Pub pub = 1; Command command = 2; Data data = 3; TaskEventStream event_stream = 4; } } // message定义 message ContainerRef { string id = 1; string name = 2; } message ContainerRequest { message List { bool all = 1; } message Deploy { uint32 task_id = 1; ContainerDeployParams params = 2; } message Start { ContainerRef target = 1; } message Stop { ContainerRef target = 1; uint32 timeout_seconds = 2; } message Kill { ContainerRef target = 1; string signal = 2; } message Remove { ContainerRef target = 1; bool force = 2; bool remove_volumes = 3; } message Config { ContainerRef target = 1; bytes config = 2; } oneof action { List list = 10; Deploy deploy = 11; Start start = 12; Stop stop = 13; Kill kill = 14; Remove remove = 15; Config config = 16; } } message ContainerDeployParams { string container_name = 1; string container_dir = 2; DockerCreateOptions create = 3; } message DockerCreateOptions { DockerContainerConfig config = 1; DockerHostConfig host_config = 2; DockerNetworkingConfig networking_config = 3; } message DockerContainerConfig { string image = 1; repeated string cmd = 2; repeated string entrypoint = 3; repeated string env = 4; map labels = 5; repeated string volumes = 6; string user = 7; string working_dir = 8; string hostname = 9; repeated DockerExposedPort exposed_ports = 10; Healthcheck healthcheck = 11; } message DockerHostConfig { repeated string binds = 1; string network_mode = 2; RestartPolicy restart_policy = 3; bool privileged = 4; repeated string cap_add = 5; repeated string cap_drop = 6; repeated DeviceMapping devices = 7; uint64 memory = 8; uint64 memory_reservation = 9; uint64 nano_cpus = 10; uint64 cpu_shares = 11; repeated Ulimit ulimits = 12; map tmpfs = 13; map sysctls = 14; repeated string extra_hosts = 15; } message DockerNetworkingConfig { repeated DockerNetworkEndpoint endpoints = 1; } message DockerNetworkEndpoint { string name = 1; } message DockerExposedPort { uint32 container_port = 1; string protocol = 2; // tcp / udp } message Healthcheck { repeated string test = 1; uint64 interval_ns = 2; uint64 timeout_ns = 3; uint32 retries = 4; } message RestartPolicy { string name = 1; // no, always, unless-stopped, on-failure uint32 maximum_retry_count = 2; } message DeviceMapping { string host_path = 1; string container_path = 2; string cgroup_permissions = 3; // 默认可填 rwm } message Ulimit { string name = 1; uint64 soft = 2; uint64 hard = 3; } message AuthRequest { bytes uuid = 1; bytes username = 2; bytes salt = 3; bytes token = 4; int32 timestamp = 5; } message Pub { bytes topic = 1; int32 qos = 2; bytes content = 3; } message Command { int32 command_type = 1; bytes command = 2; } message Data { bytes route_key = 1; bytes metric = 2; } message TaskEventStream { int32 task_id = 1; bytes type = 2; bytes stream = 3; }