2025-05-07 22:29:47 +08:00

58 lines
1.8 KiB
Erlang

%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%% 数据类型统一为 LineProtocol
%%% @end
%%% Created : 06. 5月 2024 18:17
%%%-------------------------------------------------------------------
-author("anlicheng").
-record(http_endpoint, {
url = <<>> :: binary(),
pool_size = 10 :: integer()
}).
-record(mqtt_endpoint, {
host = <<>> :: binary(),
port = 0 :: integer(),
client_id = <<>> :: binary(),
username = <<>> :: binary(),
password = <<>> :: binary(),
topic = <<>> :: binary(),
qos = 0 :: integer()
}).
-record(kafka_endpoint, {
username = <<>> :: binary(),
password = <<>> :: binary(),
bootstrap_servers = [] :: [binary()],
topic = <<>> :: binary()
}).
-record(mysql_endpoint, {
host = <<>> :: binary(),
port = 0 :: integer(),
username = <<>> :: binary(),
password = <<>> :: binary(),
database = <<>> :: binary(),
table_name = <<>> :: binary(),
pool_size = 10 :: integer()
}).
-record(endpoint, {
id :: integer(),
%% 标题描述
title = <<>> :: binary(),
mapper = <<>> :: binary(),
%% 数据转换规则,基于
%% fun(LocationCode :: binary(), Fields :: [{<<"key">> => <<>>, <<"value">> => <<>>, <<"unit">> => <<>>}])
%% fun(LocationCode :: binary(), Fields :: [{<<"key">> => <<>>, <<"value">> => <<>>, <<"unit">> => <<>>}], Timestamp :: integer())
mapper_fun = fun(_, Fields) -> Fields end :: fun(),
%% 配置项, 格式: #{<<"protocol">> => <<"http|https|ws|kafka|mqtt">>, <<"args">> => #{}}
config = #http_endpoint{} :: #http_endpoint{} | #mqtt_endpoint{} | #kafka_endpoint{} | #mysql_endpoint{},
%% 更新时间
updated_at = 0 :: integer(),
%% 创建时间
created_at = 0 :: integer()
}).