endpoint alias name use gproc

This commit is contained in:
anlicheng 2025-09-10 11:06:14 +08:00
parent 6abfbbc03a
commit 60a3fe9af4
4 changed files with 5 additions and 4 deletions

View File

@ -47,7 +47,7 @@ get_alias_name(Name) when is_binary(Name) ->
-spec get_alias_pid(Name :: binary()) -> undefined | pid().
get_alias_pid(Name) when is_binary(Name) ->
iot_name_server:whereis_alias(get_alias_name(Name)).
gproc:whereis_name({n, l, get_alias_name(Name)}).
-spec forward(Pid :: pid(), ServiceId :: binary(), Metric :: binary()) -> no_return().
forward(Pid, ServiceId, Metric) when is_pid(Pid), is_binary(ServiceId), is_binary(Metric) ->

View File

@ -46,7 +46,7 @@ start_link(LocalName, AliasName, Endpoint = #endpoint{config = #http_endpoint{}}
{stop, Reason :: term()} | ignore).
init([AliasName, Endpoint]) ->
Buffer = endpoint_buffer:new(Endpoint, 10),
iot_name_server:register(AliasName, self()),
true = gproc:reg({n, l, AliasName}),
{ok, #state{endpoint = Endpoint, buffer = Buffer}}.
%% @private

View File

@ -51,8 +51,9 @@ start_link(LocalName, AliasName, Endpoint = #endpoint{}) when is_atom(LocalName)
%% gen_statem:start_link/[3,4], this function is called by the new
%% process to initialize.
init([AliasName, Endpoint = #endpoint{id = Id}]) ->
iot_name_server:register(AliasName, self()),
erlang:process_flag(trap_exit, true),
true = gproc:reg({n, l, AliasName}),
%% ,
erlang:start_timer(0, self(), connect),
%%

View File

@ -53,8 +53,8 @@ start_link(LocalName, AliasName, Endpoint = #endpoint{}) when is_atom(LocalName)
%% gen_statem:start_link/[3,4], this function is called by the new
%% process to initialize.
init([AliasName, Endpoint]) ->
iot_name_server:register(AliasName, self()),
erlang:process_flag(trap_exit, true),
true = gproc:reg({n, l, AliasName}),
%% ,
erlang:start_timer(0, self(), create_postman),
%%