fix
This commit is contained in:
parent
7e4611d16b
commit
63d6a8f264
@ -20,7 +20,7 @@
|
||||
%% API
|
||||
-export([start_link/2]).
|
||||
-export([get_name/1, get_pid/1, attach_channel/3]).
|
||||
-export([push_envs/3, invoke/3]).
|
||||
-export([invoke/3]).
|
||||
-export([metric_data/4, send_event/3]).
|
||||
|
||||
%% gen_server callbacks
|
||||
@ -53,10 +53,6 @@ get_name(ContainerId) when is_binary(ContainerId) ->
|
||||
get_pid(ContainerId) when is_binary(ContainerId) ->
|
||||
whereis(get_name(ContainerId)).
|
||||
|
||||
-spec push_envs(Pid :: pid(), Ref :: reference(), Envs :: binary()) -> no_return().
|
||||
push_envs(Pid, Ref, Envs) when is_pid(Pid), is_binary(Envs) ->
|
||||
gen_server:cast(Pid, {push_envs, Ref, self(), Envs}).
|
||||
|
||||
-spec invoke(Pid :: pid(), Ref :: reference(), Payload :: binary()) -> no_return().
|
||||
invoke(Pid, Ref, Payload) when is_pid(Pid), is_reference(Ref), is_binary(Payload) ->
|
||||
gen_server:cast(Pid, {invoke, Ref, self(), Payload}).
|
||||
@ -142,19 +138,6 @@ handle_cast({send_event, EventType, Params}, State = #state{container_id = Conta
|
||||
lager:debug("[efka_service] send_event, container_id: ~p, meta: ~p, event_type: ~p, params: ~p", [ContainerId, MetaTag, EventType, Params]),
|
||||
{noreply, State};
|
||||
|
||||
%% 推送配置项目
|
||||
handle_cast({push_envs, Ref, ReceiverPid, Envs}, State = #state{channel_pid = ChannelPid, container_id = ContainerId, inflight = Inflight, callbacks = Callbacks}) ->
|
||||
case is_pid(ChannelPid) andalso is_process_alive(ChannelPid) of
|
||||
true ->
|
||||
ws_channel:push_config(ChannelPid, Ref, self(), Envs),
|
||||
%% 设置成功,需要更新微服务的配置
|
||||
CB = fun() -> service_model:set_config(ContainerId, Envs) end,
|
||||
{noreply, State#state{inflight = maps:put(Ref, ReceiverPid, Inflight), callbacks = maps:put(Ref, CB, Callbacks)}};
|
||||
false ->
|
||||
ReceiverPid ! {service_reply, Ref, {error, <<"channel is not alive">>}},
|
||||
{noreply, State}
|
||||
end;
|
||||
|
||||
%% 推送配置项目
|
||||
handle_cast({invoke, Ref, ReceiverPid, Payload}, State = #state{channel_pid = ChannelPid, inflight = Inflight}) ->
|
||||
case is_pid(ChannelPid) andalso is_process_alive(ChannelPid) of
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
packet_id = 1,
|
||||
container_pid :: undefined | pid(),
|
||||
is_registered = false :: boolean(),
|
||||
|
||||
%% 请求响应的对应关系, #{packet_id => {ReceiverPid, Ref}}; 自身的inflight需要超时逻辑处理
|
||||
inflight = #{}
|
||||
}).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user