ekfa/apps/efka/proto/message.proto
2026-07-07 22:53:46 +08:00

193 lines
3.1 KiB
Protocol Buffer

syntax = "proto3";
// iot <-> efka protocol payload definitions.
//
// The transport frame keeps the first byte as the coarse message class:
//
// [CLASS_REQUEST][protobuf(Request)]
// [CLASS_RESPONSE][protobuf(Response)]
// [CLASS_COMMAND][protobuf(Command)]
// [CLASS_COMMAND_RESPONSE][protobuf(CommandResponse)]
// [CLASS_MESSAGE][protobuf(Message)]
// [CLASS_STREAM][protobuf(Stream)]
//
// HTTP proxy bytes carried by Stream.Data are transparent payload bytes.
message Request {
uint32 packet_id = 1;
message AuthRequest {
bytes uuid = 1;
bytes token = 2;
uint64 timestamp = 3;
}
oneof body {
AuthRequest auth_request = 10;
}
}
message Response {
uint32 packet_id = 1;
message Error {
uint32 code = 1;
bytes reason = 2;
}
message AuthResponse {
}
oneof body {
AuthResponse auth_response = 10;
Error error = 11;
}
}
message Command {
uint32 packet_id = 1;
message Container {
message ContainerTarget {
bytes name = 1;
bytes id = 2;
}
message ContainerList {
}
message ContainerDeploy {
uint32 task_id = 1;
// The current deploy config is still an application-level structured
// payload. Keep it opaque until the Docker create schema is finalized.
bytes params = 2;
}
message ContainerStart {
ContainerTarget target = 1;
}
message ContainerStop {
ContainerTarget target = 1;
uint32 timeout_seconds = 2;
}
message ContainerKill {
ContainerTarget target = 1;
bytes signal = 2;
}
message ContainerRemove {
ContainerTarget target = 1;
bool force = 2;
bool remove_volumes = 3;
}
message ContainerConfig {
ContainerTarget target = 1;
bytes config = 2;
}
oneof action {
ContainerList list = 1;
ContainerDeploy deploy = 2;
ContainerStart start = 3;
ContainerStop stop = 4;
ContainerKill kill = 5;
ContainerRemove remove = 6;
ContainerConfig config = 7;
}
}
oneof body {
Container container = 10;
}
}
message CommandResponse {
uint32 packet_id = 1;
message Error {
uint32 code = 1;
bytes reason = 2;
}
oneof body {
bytes result = 10;
Error error = 11;
}
}
message Message {
message Ping {
}
message Pong {
}
message Pub {
bytes topic = 1;
uint32 qos = 2;
bytes content = 3;
}
message MetricData {
bytes route_key = 1;
bytes metric = 2;
}
message TaskEvent {
uint32 task_id = 1;
bytes type = 2;
bytes stream = 3;
}
oneof body {
Ping ping = 10;
Pong pong = 11;
Pub pub = 12;
MetricData metric_data = 13;
TaskEvent task_event = 14;
}
}
message Stream {
uint32 stream_id = 1;
message Open {
}
message Opened {
}
message OpenError {
bytes reason = 1;
}
message Data {
bytes bytes = 1;
}
message Fin {
}
message Reset {
bytes reason = 1;
}
oneof payload {
Open open = 10;
Opened opened = 11;
OpenError open_error = 12;
Data data = 13;
Fin fin = 14;
Reset reset = 15;
}
}