diff --git a/apps/emqx/src/emqx_channel.erl b/apps/emqx/src/emqx_channel.erl index a3480e232..1f51c15b1 100644 --- a/apps/emqx/src/emqx_channel.erl +++ b/apps/emqx/src/emqx_channel.erl @@ -259,7 +259,8 @@ init( mountpoint => MountPoint, is_bridge => false, is_superuser => false, - enable_authn => maps:get(enable_authn, Opts, true) + enable_authn => maps:get(enable_authn, Opts, true), + attrs => #{} }, Zone ), diff --git a/apps/emqx/src/emqx_cm.erl b/apps/emqx/src/emqx_cm.erl index c14058f9a..ac41c2da4 100644 --- a/apps/emqx/src/emqx_cm.erl +++ b/apps/emqx/src/emqx_cm.erl @@ -221,7 +221,7 @@ get_chan_info(ClientId, ChanPid) -> wrap_rpc(emqx_cm_proto_v2:get_chan_info(ClientId, ChanPid)). %% @doc Update infos of the channel. --spec set_chan_info(emqx_types:clientid(), emqx_types:attrs()) -> boolean(). +-spec set_chan_info(emqx_types:clientid(), emqx_types:channel_attrs()) -> boolean(). set_chan_info(ClientId, Info) when ?IS_CLIENTID(ClientId) -> Chan = {ClientId, self()}, try diff --git a/apps/emqx/src/emqx_types.erl b/apps/emqx/src/emqx_types.erl index 99a71e20b..3883991b4 100644 --- a/apps/emqx/src/emqx_types.erl +++ b/apps/emqx/src/emqx_types.erl @@ -54,7 +54,8 @@ password/0, peerhost/0, peername/0, - protocol/0 + protocol/0, + client_attrs/0 ]). -export_type([ @@ -106,7 +107,7 @@ -export_type([ caps/0, - attrs/0, + channel_attrs/0, infos/0, stats/0 ]). @@ -189,8 +190,11 @@ anonymous => boolean(), cn => binary(), dn => binary(), + %% extra attributes + attrs => client_attrs(), atom() => term() }. +-type client_attrs() :: #{binary() => binary()}. -type clientid() :: binary() | atom(). -type username() :: option(binary()). -type password() :: option(binary()). @@ -270,7 +274,7 @@ -type command() :: #command{}. -type caps() :: emqx_mqtt_caps:caps(). --type attrs() :: #{atom() => term()}. +-type channel_attrs() :: #{atom() => term()}. -type infos() :: #{atom() => term()}. -type stats() :: [{atom(), term()}].