%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%% 数据类型统一为 LineProtocol
%%% @end
%%% Created : 06. 5月 2024 18:17
%%%-------------------------------------------------------------------
-author("anlicheng").

-record(http_endpoint, {
    url = <<>> :: binary(),
    token = <<>> :: 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, {
    % {mechanism :: atom(), username = <<>> :: binary(), password = <<>> :: binary()}
    sasl_config :: undefined | tuple(),
    bootstrap_servers = [] :: [{string(), integer()}],
    topic = <<>> :: binary()
}).

-record(endpoint, {
    id :: integer(),
    %% 全局唯一，在路由规则中通过名称来指定
    matcher :: binary(),
    %% 标题描述
    title = <<>> :: binary(),
    %% 配置项, 格式: #{<<"protocol">> => <<"http|https|ws|kafka|mqtt">>, <<"args">> => #{}}
    config = #http_endpoint{} :: #http_endpoint{} | #mqtt_endpoint{} | #kafka_endpoint{},
    status = 0,
    %% 更新时间
    updated_at = 0 :: integer(),
    %% 创建时间
    created_at = 0 :: integer()
}).