ekfa/apps/efka/include/efka.hrl
2025-09-17 17:41:28 +08:00

100 lines
2.5 KiB
Erlang
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%% 扩展部分, 1: 支持基于topic的pub/sub机制; 2. 基于target的单点通讯和广播
%%% @end
%%% Created : 21. 4月 2025 17:28
%%%-------------------------------------------------------------------
-author("anlicheng").
%% efka主动发起的消息体类型, 消息大类
-define(PACKET_REQUEST, 16#01).
-define(PACKET_RESPONSE, 16#02).
%% efka主动发起不需要返回的数据
-define(PACKET_CAST, 16#03).
%% 服务器基于pub/sub的消息, 消息大类
-define(PACKET_PUB, 16#04).
%% push调用不需要返回, 消息大类
-define(PACKET_COMMAND, 16#05).
%% 服务器主动发起的RPC调用
%% 服务端不能直接和Service通讯链路太麻烦了,并且服务端也不知道如何和服务通讯
-define(PACKET_RPC, 16#10).
-define(PACKET_RPC_REPLY, 16#11).
%% ping包客户端主动发起
-define(PACKET_PING, 16#FF).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 二级分类定义
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 主机端上报数据类型标识
-define(MESSAGE_AUTH_REQUEST, 16#01).
-define(MESSAGE_AUTH_REPLY, 16#02).
-define(MESSAGE_PUB, 16#03).
-define(MESSAGE_COMMAND, 16#04).
-define(MESSAGE_RPC_DEPLOY, 16#05).
-define(MESSAGE_RPC_CONTAINER, 16#06).
-define(MESSAGE_DATA, 16#07).
-define(MESSAGE_EVENT, 16#08).
%%%% 命令类型子分类, 不需要返回值
%% 授权
-define(COMMAND_AUTH, 16#08).
%%%% 主动推送的消息类型子分类, 需要返回值
-define(RPC_DEPLOY, 16#01).
-define(RPC_START_CONTAINER, 16#02).
-define(RPC_STOP_CONTAINER, 16#03).
-define(RPC_CONFIG_CONTAINER, 16#04).
-record(auth_request, {
uuid :: binary(),
username :: binary(),
salt :: binary(),
token :: binary(),
timestamp :: integer()
}).
-record(auth_reply, {
code :: integer(),
message :: binary()
}).
-record(pub, {
topic :: binary(),
content :: binary()
}).
-record(command, {
command_type :: integer(),
command :: binary()
}).
-record(rpc_deploy, {
task_id :: integer(),
config :: binary()
}).
-record(rpc_container, {
method :: binary(),
container_name :: binary(),
params = <<>> :: binary()
}).
-record(data, {
service_id :: binary(),
device_uuid :: binary(),
route_key :: binary(),
metric :: binary()
}).
-record(event, {
service_id :: binary(),
event_type :: integer(),
params :: binary()
}).