From a687abdefde6594832786eab89043b708730cfba Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Sun, 26 Apr 2026 16:31:34 +0800 Subject: [PATCH] fix proto --- proto/service.proto | 54 +++++++++++++++++++++++++++++++++++++++++++++ rebar.config | 4 ++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 proto/service.proto diff --git a/proto/service.proto b/proto/service.proto new file mode 100644 index 0000000..96d7a61 --- /dev/null +++ b/proto/service.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +// 微服务通过 ws_channel 与 efka 之间的通道消息定义。 +// 该协议用于替代当前基于 JSON 的请求/响应/推送格式。 + +message ServiceRequest { + uint32 packet_id = 1; + + message Register { + string service_id = 1; + } + + message Subscribe { + string topic = 1; + } + + oneof request { + Register register = 10; + Subscribe subscribe = 11; + } +} + +message ServiceReply { + uint32 packet_id = 1; + + message Error { + int32 code = 1; + string message = 2; + } + + oneof reply { + bytes result = 10; + Error error = 11; + } +} + +message ServiceCast { + + message MetricData { + bytes route_key = 1; + bytes metric = 2; + } + + message TopicEvent { + string topic = 1; + bytes content = 2; + } + + oneof body { + TopicEvent topic_event = 10; + MetricData metric_data = 11; + } + +} diff --git a/rebar.config b/rebar.config index 9c5b882..81d46f6 100644 --- a/rebar.config +++ b/rebar.config @@ -8,8 +8,8 @@ % 核心:强制指定 proto 路径 + 输出到你的 apps/sdlan % ====================== {gpb_opts, [ - {i, "../proto"}, % 共享 proto 文件路径 - {src_dirs, ["../proto"]}, % 源码目录(必须) + {i, "proto"}, % 共享 proto 文件路径 + {src_dirs, ["proto"]}, % 源码目录(必须) {f, ["service.proto"]}, recursive, % 递归查找 proto 文件 {module_name_suffix, "_pb"}, % 生成模块后缀