Compare commits

..

No commits in common. "abedbd0f1e48ddbfb2f03ac8a782c6a3d9f0d9bb" and "cc03613a72db9fe10f43de7f80ba17e218299986" have entirely different histories.

13 changed files with 287 additions and 394 deletions

View File

@ -19,8 +19,8 @@
-define(PACKET_COMMAND, 16#04). -define(PACKET_COMMAND, 16#04).
%% %%
-define(PACKET_ASYNC_CALL, 16#05). -define(PACKET_PUSH, 16#05).
-define(PACKET_ASYNC_CALL_REPLY, 16#06). -define(PACKET_PUSH_REPLY, 16#06).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% %%%%
@ -41,7 +41,7 @@
%%%% , %%%% ,
%%
-define(PUSH_DEPLOY, 16#01). -define(PUSH_DEPLOY, 16#01).
-define(PUSH_SERVICE_CONFIG, 16#02). %%
-define(PUSH_INVOKE, 16#03). -define(PUSH_SERVICE_CONFIG, 16#02).
-define(PUSH_TASK_LOG, 16#04).

View File

@ -35,9 +35,9 @@
}). }).
-endif. -endif.
-ifndef('ASYNC_CALL_REPLY_PB_H'). -ifndef('PUSH_REPLY_PB_H').
-define('ASYNC_CALL_REPLY_PB_H', true). -define('PUSH_REPLY_PB_H', true).
-record(async_call_reply, -record(push_reply,
{code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits {code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
result = <<>> :: unicode:chardata() | undefined, % = 2, optional result = <<>> :: unicode:chardata() | undefined, % = 2, optional
message = <<>> :: unicode:chardata() | undefined % = 3, optional message = <<>> :: unicode:chardata() | undefined % = 3, optional
@ -53,13 +53,6 @@
}). }).
-endif. -endif.
-ifndef('FETCH_TASK_LOG_PB_H').
-define('FETCH_TASK_LOG_PB_H', true).
-record(fetch_task_log,
{task_id = 0 :: non_neg_integer() | undefined % = 1, optional, 32 bits
}).
-endif.
-ifndef('INVOKE_PB_H'). -ifndef('INVOKE_PB_H').
-define('INVOKE_PB_H', true). -define('INVOKE_PB_H', true).
-record(invoke, -record(invoke,
@ -69,9 +62,9 @@
}). }).
-endif. -endif.
-ifndef('PUSH_SERVICE_CONFIG_PB_H'). -ifndef('SERVICE_CONFIG_PB_H').
-define('PUSH_SERVICE_CONFIG_PB_H', true). -define('SERVICE_CONFIG_PB_H', true).
-record(push_service_config, -record(service_config,
{service_id = <<>> :: unicode:chardata() | undefined, % = 1, optional {service_id = <<>> :: unicode:chardata() | undefined, % = 1, optional
config_json = <<>> :: unicode:chardata() | undefined, % = 2, optional config_json = <<>> :: unicode:chardata() | undefined, % = 2, optional
timeout = 0 :: non_neg_integer() | undefined % = 3, optional, 32 bits timeout = 0 :: non_neg_integer() | undefined % = 3, optional, 32 bits

View File

@ -168,13 +168,12 @@ handle_info({timeout, _, create_transport}, State = #state{status = ?STATE_DENIE
handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, transport_pid = TransportPid}) when is_pid(TransportPid) -> handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, transport_pid = TransportPid}) when is_pid(TransportPid) ->
case Reply of case Reply of
ok -> ok ->
AuthBin = auth_request(), efka_transport:auth_request(TransportPid, 5000),
efka_transport:auth_request(TransportPid, AuthBin, 5000),
{noreply, State#state{status = ?STATE_AUTH}}; {noreply, State#state{status = ?STATE_AUTH}};
{error, Reason} -> {error, Reason} ->
lager:debug("[efka_agent] connect failed, error: ~p, pid: ~p", [Reason, TransportPid]), efka_logger:debug("[efka_agent] connect failed, error: ~p, pid: ~p", [Reason, TransportPid]),
efka_transport:stop(TransportPid), efka_transport:stop(TransportPid),
{noreply, State#state{status = ?STATE_DENIED}} {noreply, ?STATE_DENIED, State#state{status = ?STATE_DENIED}}
end; end;
%% auth回复 %% auth回复
@ -201,7 +200,7 @@ handle_info({auth_reply, Reply}, State = #state{status = ?STATE_AUTH, transport_
{noreply, State#state{status = ?STATE_RESTRICTED}}; {noreply, State#state{status = ?STATE_RESTRICTED}};
2 -> 2 ->
% %
lager:debug("[efka_agent] auth failed, message: ~p", [Message]), efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
efka_transport:stop(TransportPid), efka_transport:stop(TransportPid),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}; {noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
_ -> _ ->
@ -226,65 +225,53 @@ handle_info({server_push, PacketId, <<?PUSH_DEPLOY:8, DeployBin/binary>>}, State
%% efka_inetd收到消息后就立即返回了 %% efka_inetd收到消息后就立即返回了
Reply = case efka_inetd:deploy(TaskId, ServiceId, TarUrl) of Reply = case efka_inetd:deploy(TaskId, ServiceId, TarUrl) of
ok -> ok ->
#async_call_reply{code = 1, message = <<"">>}; #push_reply{code = 1, message = <<"">>};
{error, Reason} when is_binary(Reason) -> {error, Reason} when is_binary(Reason) ->
#async_call_reply{code = 0, message = Reason} #push_reply{code = 0, message = Reason}
end, end,
is_pid(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)), is_pid(TransportPid) andalso efka_transport:push_response(TransportPid, PacketId, message_pb:encode_msg(Reply)),
{noreply, State}; {noreply, State};
%% config.json配置信息 %% config.json配置信息
handle_info({server_push, PacketId, <<?PUSH_SERVICE_CONFIG:8, ConfigBin/binary>>}, State = #state{transport_pid = TransportPid, inflight = Inflight}) -> handle_info({server_push, PacketId, <<?PUSH_SERVICE_CONFIG:8, ConfigBin/binary>>}, State = #state{transport_pid = TransportPid, inflight = Inflight}) ->
#push_service_config{service_id = ServiceId, config_json = ConfigJson, timeout = Timeout} = message_pb:decode_msg(ConfigBin, push_service_config), #service_config{service_id = ServiceId, config_json = ConfigJson, timeout = Timeout} = message_pb:decode_msg(ConfigBin, service_config),
case efka_service:get_pid(ServiceId) of case efka_service:get_pid(ServiceId) of
undefined -> undefined ->
Reply = #async_call_reply{code = 0, message = <<"service not run">>}, Reply = #push_reply{code = 0, message = <<"service not run">>},
is_pid(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)), is_pid(TransportPid) andalso efka_transport:push_response(TransportPid, PacketId, message_pb:encode_msg(Reply)),
{noreply, State}; {noreply, State};
ServicePid when is_pid(ServicePid) -> ServicePid when is_pid(ServicePid) ->
Ref = make_ref(), Ref = make_ref(),
%% %%
efka_service:push_config(ServicePid, Ref, ConfigJson), efka_service:push_config(ServicePid, Ref, ConfigJson),
%% %%
erlang:start_timer(Timeout, self(), {request_timeout, Ref}), erlang:start_timer(Timeout * 1000, self(), {request_timeout, Ref}),
{noreply, State#state{inflight = maps:put(Ref, PacketId, Inflight)}} {noreply, State#state{inflight = maps:put(Ref, PacketId, Inflight)}}
end; end;
%% %%
handle_info({server_push, PacketId, <<?PUSH_INVOKE:8, InvokeBin/binary>>}, State = #state{status = ?STATE_ACTIVATED, inflight = Inflight}) -> handle_info({server_push, PacketId, Invoke = #invoke{service_id = ServiceId, payload = Payload, timeout = Timeout}},
#invoke{service_id = ServiceId, payload = Payload, timeout = Timeout} = message_pb:decode_msg(InvokeBin, invoke), State = #state{status = ?STATE_ACTIVATED, inflight = Inflight}) ->
efka_logger:debug("[efka_agent] get invoke: ~p", [Invoke]),
%% %%
case efka_service:get_pid(ServiceId) of case efka_service:get_pid(ServiceId) of
undefined -> undefined ->
Reply = #async_call_reply{code = 0, message = <<"micro_service not run">>, result = <<>>}, Reply = #push_reply{code = 0, message = <<"micro_service not run">>, result = <<>>},
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State), safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State}; {noreply, State};
ServicePid when is_pid(ServicePid) -> ServicePid when is_pid(ServicePid) ->
Ref = make_ref(), Ref = make_ref(),
efka_service:invoke(ServicePid, Ref, Payload), efka_service:invoke(ServicePid, Ref, Payload),
%% %%
erlang:start_timer(Timeout, self(), {request_timeout, Ref}), erlang:start_timer(Timeout * 1000, self(), {request_timeout, Ref}),
{noreply, State#state{inflight = maps:put(Ref, PacketId, Inflight)}} {noreply, State#state{inflight = maps:put(Ref, PacketId, Inflight)}}
end; end;
%% task_log
handle_info({server_push, PacketId, <<?PUSH_TASK_LOG:8, TaskLogBin/binary>>}, State = #state{status = ?STATE_ACTIVATED}) ->
#fetch_task_log{task_id = TaskId} = message_pb:decode_msg(TaskLogBin, fetch_task_log),
{ok, Logs} = efka_inetd_task_log:get_logs(TaskId),
Reply = case length(Logs) > 0 of
true ->
Result = iolist_to_binary(jiffy:encode(Logs, [force_utf8])),
#async_call_reply{code = 1, result = Result};
false ->
#async_call_reply{code = 1, result = <<"[]">>}
end,
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State};
%% %%
handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transport_pid = TransportPid, status = Status}) -> handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transport_pid = TransportPid, status = Status}) ->
case {Auth, Status} of case {Auth, Status} of
@ -292,8 +279,7 @@ handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transpor
{noreply, State}; {noreply, State};
{1, ?STATE_DENIED} -> {1, ?STATE_DENIED} ->
%% , %% ,
AuthRequestBin = auth_request(), efka_transport:auth_request(TransportPid, 5000),
efka_transport:auth_request(TransportPid, AuthRequestBin, 5000),
{noreply, State#state{status = ?STATE_AUTH}}; {noreply, State#state{status = ?STATE_AUTH}};
{0, _} -> {0, _} ->
%% %%
@ -302,7 +288,7 @@ handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transpor
%% %%
handle_info({server_pub, Topic, Content}, State = #state{status = ?STATE_ACTIVATED}) -> handle_info({server_pub, Topic, Content}, State = #state{status = ?STATE_ACTIVATED}) ->
lager:debug("[efka_agent] get pub topic: ~p, content: ~p", [Topic, Content]), efka_logger:debug("[efka_agent] get pub topic: ~p, content: ~p", [Topic, Content]),
%% %%
efka_subscription:publish(Topic, Content), efka_subscription:publish(Topic, Content),
@ -316,11 +302,11 @@ handle_info({service_reply, Ref, EmsReply}, State = #state{inflight = Inflight})
{PacketId, NInflight} -> {PacketId, NInflight} ->
Reply = case EmsReply of Reply = case EmsReply of
ok -> ok ->
#async_call_reply{code = 1, message = <<"">>, result = <<>>}; #push_reply{code = 1, message = <<"">>, result = <<>>};
{error, Reason} -> {error, Reason} ->
#async_call_reply{code = 0, message = Reason} #push_reply{code = 0, message = Reason}
end, end,
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State), safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State#state{inflight = NInflight}} {noreply, State#state{inflight = NInflight}}
end; end;
@ -331,15 +317,15 @@ handle_info({timeout, _, {request_timeout, Ref}}, State = #state{inflight = Infl
error -> error ->
{noreply, State}; {noreply, State};
{PacketId, NInflight} -> {PacketId, NInflight} ->
Reply = #async_call_reply{code = 0, message = <<"reqeust timeout">>, result = <<>>}, Reply = #push_reply{code = 0, message = <<"reqeust timeout">>, result = <<>>},
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State), safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State#state{inflight = NInflight}} {noreply, State#state{inflight = NInflight}}
end; end;
%% transport进程退出 %% transport进程退出
handle_info({'EXIT', TransportPid, Reason}, State = #state{transport_pid = TransportPid}) -> handle_info({'EXIT', TransportPid, Reason}, State = #state{transport_pid = TransportPid}) ->
lager:debug("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]), efka_logger:debug("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
erlang:start_timer(5000, self(), create_transport), erlang:start_timer(5000, self(), create_transport),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}; {noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
@ -369,10 +355,10 @@ code_change(_OldVsn, State = #state{}, _Extra) ->
%%%=================================================================== %%%===================================================================
%% %%
-spec safe_async_call_reply(PacketId :: integer(), Reply :: binary(), State :: #state{}) -> no_return(). -spec safe_push_response(PacketId :: integer(), Reply :: binary(), State :: #state{}) -> no_return().
safe_async_call_reply(PacketId, Reply, #state{status = ?STATE_ACTIVATED, transport_pid = TransportPid}) when is_integer(PacketId), is_binary(Reply), is_pid(TransportPid) -> safe_push_response(PacketId, Reply, #state{status = ?STATE_ACTIVATED, transport_pid = TransportPid}) when is_integer(PacketId), is_binary(Reply), is_pid(TransportPid) ->
is_process_alive(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, Reply); is_process_alive(TransportPid) andalso efka_transport:push_response(TransportPid, PacketId, Reply);
safe_async_call_reply(_PacketId, _Reply, #state{}) -> safe_push_response(_PacketId, _Reply, #state{}) ->
ok. ok.
%% %%
@ -380,20 +366,4 @@ safe_async_call_reply(_PacketId, _Reply, #state{}) ->
safe_send(Method, Packet, #state{status = ?STATE_ACTIVATED, transport_pid = TransportPid}) when is_pid(TransportPid) -> safe_send(Method, Packet, #state{status = ?STATE_ACTIVATED, transport_pid = TransportPid}) when is_pid(TransportPid) ->
efka_transport:send(TransportPid, Method, Packet); efka_transport:send(TransportPid, Method, Packet);
safe_send(Method, Packet, #state{}) -> safe_send(Method, Packet, #state{}) ->
ok = cache_model:insert(Method, Packet). ok = cache_model:insert(Method, Packet).
-spec auth_request() -> binary().
auth_request() ->
{ok, AuthInfo} = application:get_env(efka, auth),
UUID = proplists:get_value(uuid, AuthInfo),
Username = proplists:get_value(username, AuthInfo),
Salt = proplists:get_value(salt, AuthInfo),
Token = proplists:get_value(token, AuthInfo),
message_pb:encode_msg(#auth_request{
uuid = unicode:characters_to_binary(UUID),
username = unicode:characters_to_binary(Username),
salt = unicode:characters_to_binary(Salt),
token = unicode:characters_to_binary(Token),
timestamp = efka_util:timestamp()
}).

View File

@ -74,9 +74,39 @@ handle_call(_Request, _From, State = #state{}) ->
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_cast(deploy, State = #state{task_id = TaskId, service_root_dir = ServiceRootDir, service_id = ServiceId, tar_url = TarUrl}) -> handle_cast(deploy, State = #state{task_id = TaskId, service_root_dir = ServiceRootDir, service_id = ServiceId, tar_url = TarUrl}) ->
do_deploy(TaskId, ServiceRootDir, ServiceId, TarUrl), case download(binary_to_list(TarUrl), ServiceRootDir) of
{stop, normal, State}; {ok, TarFile, CostTs} ->
handle_cast(_Request, State) -> Log = io_lib:format("download: ~p completed, cost time: ~p(ms)", [binary_to_list(TarUrl), CostTs]),
efka_inetd_task_log:stash(TaskId, list_to_binary(Log)),
{ok, WorkDir} = make_work_dir(ServiceRootDir),
%%
Result = delete_directory(WorkDir),
lager:debug("delete_directory result is: ~p", [Result]),
case tar_extract(TarFile, WorkDir) of
ok ->
%% lock文件
touch_lock(ServiceRootDir, TarUrl),
%%
ok = service_model:insert(#service{
service_id = ServiceId,
tar_url = TarUrl,
%%
root_dir = ServiceRootDir,
params = <<"">>,
metrics = <<"">>,
%% 0: , 1:
status = 0
}),
efka_inetd_task_log:stash(TaskId, <<"deploy success">>);
{error, Reason} ->
TarLog = io_lib:format("tar decompression: ~p, error: ~p", [filename:basename(TarFile), Reason]),
efka_inetd_task_log:stash(TaskId, list_to_binary(TarLog))
end;
{error, Reason} ->
DownloadLog = io_lib:format("download: ~p, error: ~p", [binary_to_list(TarUrl), Reason]),
efka_inetd_task_log:stash(TaskId, list_to_binary(DownloadLog))
end,
{stop, normal, State}. {stop, normal, State}.
%% @private %% @private
@ -110,47 +140,16 @@ code_change(_OldVsn, State = #state{}, _Extra) ->
%%% Internal functions %%% Internal functions
%%%=================================================================== %%%===================================================================
-spec do_deploy(TaskId :: integer(), ServiceRootDir :: string(), ServiceId :: binary(), TarUrl :: binary()) -> no_return(). %%
do_deploy(TaskId, ServiceRootDir, ServiceId, TarUrl) when is_integer(TaskId), is_list(ServiceRootDir), is_binary(ServiceId), is_binary(TarUrl) -> -spec make_work_dir(ServiceRootDir :: string()) -> {ok, WorkDir :: string()}.
case download(binary_to_list(TarUrl), ServiceRootDir) of make_work_dir(ServiceRootDir) when is_list(ServiceRootDir) ->
{ok, TarFile, CostTs} -> %%
Log = io_lib:format("download: ~p completed, cost time: ~p(ms)", [binary_to_list(TarUrl), CostTs]), WorkDir = ServiceRootDir ++ "/work_dir/",
efka_inetd_task_log:stash(TaskId, list_to_binary(Log)), ok = filelib:ensure_dir(WorkDir),
{ok, WorkDir}.
%%
WorkDir = ServiceRootDir ++ "/work_dir/",
ok = filelib:ensure_dir(WorkDir),
%%
Result = delete_directory(WorkDir),
lager:debug("delete_directory result is: ~p", [Result]),
case tar_extract(TarFile, WorkDir) of
ok ->
%% lock文件
touch_lock(ServiceRootDir, TarUrl),
%%
ok = service_model:insert(#service{
service_id = ServiceId,
tar_url = TarUrl,
%%
root_dir = ServiceRootDir,
params = <<"">>,
metrics = <<"">>,
%% 0: , 1:
status = 0
}),
efka_inetd_task_log:stash(TaskId, <<"deploy success">>);
{error, Reason} ->
TarLog = io_lib:format("tar decompression: ~p, error: ~p", [filename:basename(TarFile), Reason]),
efka_inetd_task_log:stash(TaskId, list_to_binary(TarLog))
end;
{error, Reason} ->
DownloadLog = io_lib:format("download: ~p, error: ~p", [binary_to_list(TarUrl), Reason]),
efka_inetd_task_log:stash(TaskId, list_to_binary(DownloadLog))
end.
%% %%
-spec delete_directory(string()) -> ok | {error, term()}. -spec delete_directory(Dir :: string()) -> ok | {error, Reason :: any()}.
delete_directory(Dir) when is_list(Dir) -> delete_directory(Dir) when is_list(Dir) ->
% %
case file:list_dir(Dir) of case file:list_dir(Dir) of
@ -172,7 +171,7 @@ delete_directory(Dir) when is_list(Dir) ->
{error, Reason} {error, Reason}
end. end.
-spec touch_lock(string(), binary()) -> boolean(). -spec touch_lock(DirName :: string(), TarUrl :: binary()) -> boolean().
touch_lock(DirName, TarUrl) when is_list(DirName), is_binary(TarUrl) -> touch_lock(DirName, TarUrl) when is_list(DirName), is_binary(TarUrl) ->
FileName = DirName ++ ".efka.lock", FileName = DirName ++ ".efka.lock",
filelib:is_file(FileName) andalso file:delete(FileName), filelib:is_file(FileName) andalso file:delete(FileName),
@ -184,7 +183,7 @@ touch_lock(DirName, TarUrl) when is_list(DirName), is_binary(TarUrl) ->
end. end.
%% %%
-spec tar_extract(string(), string()) -> ok | {error, term()}. -spec tar_extract(TarFile :: string(), TargetDir :: string()) -> ok | {error, Reason :: term()}.
tar_extract(TarFile, TargetDir) when is_list(TarFile), is_list(TargetDir) -> tar_extract(TarFile, TargetDir) when is_list(TarFile), is_list(TargetDir) ->
%% %%
Ext = filename:extension(TarFile), Ext = filename:extension(TarFile),
@ -196,8 +195,7 @@ tar_extract(TarFile, TargetDir) when is_list(TarFile), is_list(TargetDir) ->
end. end.
%% %%
-spec download(Url :: string(), TargetDir :: string()) -> -spec download(Url :: string(), TargetDir :: string()) -> {ok, TarFile :: string(), CostTs :: integer()} | {error, Reason :: term()}.
{ok, TarFile :: string(), CostTs :: integer()} | {error, Reason :: term()}.
download(Url, TargetDir) when is_list(Url), is_list(TargetDir) -> download(Url, TargetDir) when is_list(Url), is_list(TargetDir) ->
SslOpts = [ SslOpts = [
{ssl, [ {ssl, [

View File

@ -0,0 +1,19 @@
%%%-------------------------------------------------------------------
%%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 29. 4 2025 22:39
%%%-------------------------------------------------------------------
-module(efka_logger).
-author("anlicheng").
%% API
-export([debug/2, notice/2]).
debug(Format, Args) ->
io:format(Format ++ "~n", Args).
notice(Format, Args) ->
io:format(Format ++ "~n", Args).

View File

@ -108,7 +108,7 @@ handle_cast({publish, Topic, Content}, State = #state{subscribers = Subscribers}
SubscriberPid ! {topic_broadcast, Topic, Content} SubscriberPid ! {topic_broadcast, Topic, Content}
end, MatchedSubscribers), end, MatchedSubscribers),
lager:debug("[efka_subscription] topic: ~p, content: ~p, match subscribers: ~p", [Topic, Content, MatchedSubscribers]), efka_logger:debug("[efka_subscription] topic: ~p, content: ~p, match subscribers: ~p", [Topic, Content, MatchedSubscribers]),
{noreply, State}. {noreply, State}.
%% @private %% @private
@ -118,12 +118,12 @@ handle_cast({publish, Topic, Content}, State = #state{subscribers = Subscribers}
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_info({'DOWN', _Ref, process, SubscriberPid, Reason}, State = #state{subscribers = Subscribers}) -> handle_info({'DOWN', _Ref, process, SubscriberPid, Reason}, State = #state{subscribers = Subscribers}) ->
lager:debug("[efka_subscription] subscriber: ~p, down with reason: ~p", [SubscriberPid, Reason]), efka_logger:debug("[efka_subscription] subscriber: ~p, down with reason: ~p", [SubscriberPid, Reason]),
NSubscribers = lists:filter(fun(#subscriber{subscriber_pid = Pid0}) -> SubscriberPid /= Pid0 end, Subscribers), NSubscribers = lists:filter(fun(#subscriber{subscriber_pid = Pid0}) -> SubscriberPid /= Pid0 end, Subscribers),
{noreply, State#state{subscribers = NSubscribers}}; {noreply, State#state{subscribers = NSubscribers}};
handle_info(Info, State = #state{}) -> handle_info(Info, State = #state{}) ->
lager:debug("[efka_subscription] get unknown info: ~p", [Info]), efka_logger:debug("[efka_subscription] get unknown info: ~p", [Info]),
{noreply, State}. {noreply, State}.
%% @private %% @private

View File

@ -66,7 +66,7 @@ init([]) ->
#{ #{
id => 'efka_tcp_server', id => 'efka_tcp_server',
start => {'efka_tcp_server', start_link, []}, start => {'efka_tcp_server', start_link, [18080]},
restart => permanent, restart => permanent,
shutdown => 2000, shutdown => 2000,
type => worker, type => worker,

View File

@ -10,22 +10,19 @@
-author("anlicheng"). -author("anlicheng").
%% API %% API
-export([start_link/0, init/0]). -export([start_link/1, init/1]).
start_link() -> start_link(Port) ->
{ok, spawn_link(?MODULE, init, [])}. {ok, spawn_link(?MODULE, init, [Port])}.
%% %%
init() -> init(Port) ->
{ok, TcpServerProps} = application:get_env(efka, tcp_server),
Port = proplists:get_value(port, TcpServerProps),
case gen_tcp:listen(Port, [binary, {packet, 4}, {active, false}, {reuseaddr, true}]) of case gen_tcp:listen(Port, [binary, {packet, 4}, {active, false}, {reuseaddr, true}]) of
{ok, ListenSocket} -> {ok, ListenSocket} ->
lager:debug("[efka_tcp_server] Server started on port ~p~n", [Port]), efka_logger:debug("Server started on port ~p~n", [Port]),
main_loop(ListenSocket); main_loop(ListenSocket);
{error, Reason} -> {error, Reason} ->
lager:debug("[efka_tcp_server] Failed to start server: ~p~n", [Reason]), efka_logger:debug("Failed to start server: ~p~n", [Reason]),
exit(Reason) exit(Reason)
end. end.
@ -38,9 +35,9 @@ main_loop(ListenSocket) ->
% %
main_loop(ListenSocket); main_loop(ListenSocket);
{error, closed} -> {error, closed} ->
lager:debug("[efka_tcp_server] Server socket closed"), efka_logger:debug("Server socket closed~n", []),
exit(tcp_closed); exit(tcp_closed);
{error, Reason} -> {error, Reason} ->
lager:debug("[efka_tcp_server] Accept error: ~p", [Reason]), efka_logger:debug("Accept error: ~p~n", [Reason]),
exit(Reason) exit(Reason)
end. end.

View File

@ -15,7 +15,7 @@
%% API %% API
-export([start_link/3]). -export([start_link/3]).
-export([connect/1, auth_request/3, send/3, async_call_reply/3, stop/1]). -export([connect/1, auth_request/2, send/3, push_response/3, stop/1]).
%% gen_server callbacks %% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@ -34,9 +34,9 @@
%%% API %%% API
%%%=================================================================== %%%===================================================================
-spec auth_request(Pid :: pid(), AuthBin :: binary(), Timeout :: integer()) -> no_return(). -spec auth_request(Pid :: pid(), Timeout :: integer()) -> no_return().
auth_request(Pid, AuthBin, Timeout) when is_pid(Pid), is_binary(AuthBin), is_integer(Timeout) -> auth_request(Pid, Timeout) when is_pid(Pid), is_integer(Timeout) ->
gen_server:cast(Pid, {auth_request, AuthBin, Timeout}). gen_server:cast(Pid, {auth_request, Timeout}).
-spec connect(Pid :: pid()) -> no_return(). -spec connect(Pid :: pid()) -> no_return().
connect(Pid) when is_pid(Pid) -> connect(Pid) when is_pid(Pid) ->
@ -46,9 +46,9 @@ connect(Pid) when is_pid(Pid) ->
send(Pid, Method, Packet) when is_pid(Pid), is_integer(Method), is_binary(Packet) -> send(Pid, Method, Packet) when is_pid(Pid), is_integer(Method), is_binary(Packet) ->
gen_server:cast(Pid, {send, Method, Packet}). gen_server:cast(Pid, {send, Method, Packet}).
-spec async_call_reply(Pid :: pid(), PacketId :: integer(), Response :: binary()) -> no_return(). -spec push_response(Pid :: pid(), PacketId :: integer(), Response :: binary()) -> no_return().
async_call_reply(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) -> push_response(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) ->
gen_server:cast(Pid, {async_call_reply, PacketId, Response}). gen_server:cast(Pid, {push_response, PacketId, Response}).
-spec stop(Pid :: pid()) -> ok. -spec stop(Pid :: pid()) -> ok.
stop(Pid) when is_pid(Pid) -> stop(Pid) when is_pid(Pid) ->
@ -108,8 +108,22 @@ handle_cast(connect, State = #state{host = Host, port = Port, parent_pid = Paren
end; end;
%% auth校验 %% auth校验
handle_cast({auth_request, AuthRequestBin, Timeout}, State = #state{parent_pid = ParentPid, socket = Socket, packet_id = PacketId}) -> handle_cast({auth_request, Timeout}, State = #state{parent_pid = ParentPid, socket = Socket, packet_id = PacketId}) ->
ok = ssl:send(Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH, AuthRequestBin/binary>>), {ok, AuthInfo} = application:get_env(efka, auth),
UUID = proplists:get_value(uuid, AuthInfo),
Username = proplists:get_value(username, AuthInfo),
Salt = proplists:get_value(salt, AuthInfo),
Token = proplists:get_value(token, AuthInfo),
RequestBin = message_pb:encode_msg(#auth_request{
uuid = unicode:characters_to_binary(UUID),
username = unicode:characters_to_binary(Username),
salt = unicode:characters_to_binary(Salt),
token = unicode:characters_to_binary(Token),
timestamp = efka_util:timestamp()
}),
ok = ssl:send(Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH, RequestBin/binary>>),
%% auth返回的结果 %% auth返回的结果
receive receive
{ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ?METHOD_AUTH, ReplyBin/binary>>} -> {ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ?METHOD_AUTH, ReplyBin/binary>>} ->
@ -121,12 +135,12 @@ handle_cast({auth_request, AuthRequestBin, Timeout}, State = #state{parent_pid =
end; end;
handle_cast({send, Method, Packet}, State = #state{socket = Socket}) -> handle_cast({send, Method, Packet}, State = #state{socket = Socket}) ->
ok = ssl:send(Socket, <<?PACKET_REQUEST, Method:8, Packet/binary>>), ok = ssl:send(Socket, <<?PACKET_REQUEST, 0:32, Method, Packet/binary>>),
{noreply, State}; {noreply, State};
%% push的消息的回复 %% push的消息的回复
handle_cast({async_call_reply, PacketId, Response}, State = #state{socket = Socket}) -> handle_cast({push_response, PacketId, Response}, State = #state{socket = Socket}) ->
ok = ssl:send(Socket, <<?PACKET_ASYNC_CALL_REPLY, PacketId:32, Response/binary>>), ok = ssl:send(Socket, <<?PACKET_PUSH_REPLY, PacketId:32, Response/binary>>),
{noreply, State}. {noreply, State}.
%% @private %% @private
@ -136,17 +150,17 @@ handle_cast({async_call_reply, PacketId, Response}, State = #state{socket = Sock
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
%% packetId的是要求返回的0 %% packetId的是要求返回的0
handle_info({ssl, Socket, <<?PACKET_COMMAND, CommandType:8, Command/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) -> handle_info({ssl, Socket, <<?PACKET_COMMAND, 0:32, CommandType:8, Command/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
ParentPid ! {server_command, CommandType, Command}, ParentPid ! {server_command, CommandType, Command},
{noreply, State}; {noreply, State};
handle_info({ssl, Socket, <<?PACKET_PUB, PubBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) -> handle_info({ssl, Socket, <<?PACKET_PUB, 0:32, PubBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
#pub{topic = Topic, content = Content} = message_pb:decode_msg(PubBin, pub), #pub{topic = Topic, content = Content} = message_pb:decode_msg(PubBin, pub),
ParentPid ! {server_pub, Topic, Content}, ParentPid ! {server_pub, Topic, Content},
{noreply, State}; {noreply, State};
handle_info({ssl, Socket, <<?PACKET_ASYNC_CALL, PacketId:32, AsyncCallBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) -> handle_info({ssl, Socket, <<?PACKET_PUSH, PacketId:32, PushBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
ParentPid ! {server_push, PacketId, AsyncCallBin}, ParentPid ! {server_push, PacketId, PushBin},
{noreply, State}; {noreply, State};
handle_info({ssl_error, Socket, Reason}, State = #state{socket = Socket}) -> handle_info({ssl_error, Socket, Reason}, State = #state{socket = Socket}) ->
@ -168,7 +182,7 @@ handle_info(Info, State = #state{}) ->
-spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()), -spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
State :: #state{}) -> term()). State :: #state{}) -> term()).
terminate(Reason, #state{}) -> terminate(Reason, #state{}) ->
lager:notice("[efka_transport] terminate with reason: ~p", [Reason]), efka_logger:notice("[efka_transport] terminate with reason: ~p", [Reason]),
ok. ok.
%% @private %% @private

View File

@ -61,15 +61,13 @@
-type pub() :: #pub{}. -type pub() :: #pub{}.
-type async_call_reply() :: #async_call_reply{}. -type push_reply() :: #push_reply{}.
-type deploy() :: #deploy{}. -type deploy() :: #deploy{}.
-type fetch_task_log() :: #fetch_task_log{}.
-type invoke() :: #invoke{}. -type invoke() :: #invoke{}.
-type push_service_config() :: #push_service_config{}. -type service_config() :: #service_config{}.
-type data() :: #data{}. -type data() :: #data{}.
@ -79,9 +77,9 @@
-type event() :: #event{}. -type event() :: #event{}.
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'async_call_reply'/0, 'deploy'/0, 'fetch_task_log'/0, 'invoke'/0, 'push_service_config'/0, 'data'/0, 'ping'/0, 'service_inform'/0, 'event'/0]). -export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'push_reply'/0, 'deploy'/0, 'invoke'/0, 'service_config'/0, 'data'/0, 'ping'/0, 'service_inform'/0, 'event'/0]).
-type '$msg_name'() :: auth_request | auth_reply | pub | async_call_reply | deploy | fetch_task_log | invoke | push_service_config | data | ping | service_inform | event. -type '$msg_name'() :: auth_request | auth_reply | pub | push_reply | deploy | invoke | service_config | data | ping | service_inform | event.
-type '$msg'() :: auth_request() | auth_reply() | pub() | async_call_reply() | deploy() | fetch_task_log() | invoke() | push_service_config() | data() | ping() | service_inform() | event(). -type '$msg'() :: auth_request() | auth_reply() | pub() | push_reply() | deploy() | invoke() | service_config() | data() | ping() | service_inform() | event().
-export_type(['$msg_name'/0, '$msg'/0]). -export_type(['$msg_name'/0, '$msg'/0]).
-if(?OTP_RELEASE >= 24). -if(?OTP_RELEASE >= 24).
@ -111,11 +109,10 @@ encode_msg(Msg, MsgName, Opts) ->
auth_request -> encode_msg_auth_request(id(Msg, TrUserData), TrUserData); auth_request -> encode_msg_auth_request(id(Msg, TrUserData), TrUserData);
auth_reply -> encode_msg_auth_reply(id(Msg, TrUserData), TrUserData); auth_reply -> encode_msg_auth_reply(id(Msg, TrUserData), TrUserData);
pub -> encode_msg_pub(id(Msg, TrUserData), TrUserData); pub -> encode_msg_pub(id(Msg, TrUserData), TrUserData);
async_call_reply -> encode_msg_async_call_reply(id(Msg, TrUserData), TrUserData); push_reply -> encode_msg_push_reply(id(Msg, TrUserData), TrUserData);
deploy -> encode_msg_deploy(id(Msg, TrUserData), TrUserData); deploy -> encode_msg_deploy(id(Msg, TrUserData), TrUserData);
fetch_task_log -> encode_msg_fetch_task_log(id(Msg, TrUserData), TrUserData);
invoke -> encode_msg_invoke(id(Msg, TrUserData), TrUserData); invoke -> encode_msg_invoke(id(Msg, TrUserData), TrUserData);
push_service_config -> encode_msg_push_service_config(id(Msg, TrUserData), TrUserData); service_config -> encode_msg_service_config(id(Msg, TrUserData), TrUserData);
data -> encode_msg_data(id(Msg, TrUserData), TrUserData); data -> encode_msg_data(id(Msg, TrUserData), TrUserData);
ping -> encode_msg_ping(id(Msg, TrUserData), TrUserData); ping -> encode_msg_ping(id(Msg, TrUserData), TrUserData);
service_inform -> encode_msg_service_inform(id(Msg, TrUserData), TrUserData); service_inform -> encode_msg_service_inform(id(Msg, TrUserData), TrUserData);
@ -226,10 +223,10 @@ encode_msg_pub(#pub{topic = F1, content = F2}, Bin, TrUserData) ->
end end
end. end.
encode_msg_async_call_reply(Msg, TrUserData) -> encode_msg_async_call_reply(Msg, <<>>, TrUserData). encode_msg_push_reply(Msg, TrUserData) -> encode_msg_push_reply(Msg, <<>>, TrUserData).
encode_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) -> encode_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin; B1 = if F1 == undefined -> Bin;
true -> true ->
begin begin
@ -294,20 +291,6 @@ encode_msg_deploy(#deploy{task_id = F1, service_id = F2, tar_url = F3}, Bin, TrU
end end
end. end.
encode_msg_fetch_task_log(Msg, TrUserData) -> encode_msg_fetch_task_log(Msg, <<>>, TrUserData).
encode_msg_fetch_task_log(#fetch_task_log{task_id = F1}, Bin, TrUserData) ->
if F1 == undefined -> Bin;
true ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= 0 -> Bin;
true -> e_varint(TrF1, <<Bin/binary, 8>>, TrUserData)
end
end
end.
encode_msg_invoke(Msg, TrUserData) -> encode_msg_invoke(Msg, <<>>, TrUserData). encode_msg_invoke(Msg, TrUserData) -> encode_msg_invoke(Msg, <<>>, TrUserData).
@ -342,10 +325,10 @@ encode_msg_invoke(#invoke{service_id = F1, payload = F2, timeout = F3}, Bin, TrU
end end
end. end.
encode_msg_push_service_config(Msg, TrUserData) -> encode_msg_push_service_config(Msg, <<>>, TrUserData). encode_msg_service_config(Msg, TrUserData) -> encode_msg_service_config(Msg, <<>>, TrUserData).
encode_msg_push_service_config(#push_service_config{service_id = F1, config_json = F2, timeout = F3}, Bin, TrUserData) -> encode_msg_service_config(#service_config{service_id = F1, config_json = F2, timeout = F3}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin; B1 = if F1 == undefined -> Bin;
true -> true ->
begin begin
@ -778,11 +761,10 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
decode_msg_2_doit(auth_request, Bin, TrUserData) -> id(decode_msg_auth_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(auth_request, Bin, TrUserData) -> id(decode_msg_auth_request(Bin, TrUserData), TrUserData);
decode_msg_2_doit(auth_reply, Bin, TrUserData) -> id(decode_msg_auth_reply(Bin, TrUserData), TrUserData); decode_msg_2_doit(auth_reply, Bin, TrUserData) -> id(decode_msg_auth_reply(Bin, TrUserData), TrUserData);
decode_msg_2_doit(pub, Bin, TrUserData) -> id(decode_msg_pub(Bin, TrUserData), TrUserData); decode_msg_2_doit(pub, Bin, TrUserData) -> id(decode_msg_pub(Bin, TrUserData), TrUserData);
decode_msg_2_doit(async_call_reply, Bin, TrUserData) -> id(decode_msg_async_call_reply(Bin, TrUserData), TrUserData); decode_msg_2_doit(push_reply, Bin, TrUserData) -> id(decode_msg_push_reply(Bin, TrUserData), TrUserData);
decode_msg_2_doit(deploy, Bin, TrUserData) -> id(decode_msg_deploy(Bin, TrUserData), TrUserData); decode_msg_2_doit(deploy, Bin, TrUserData) -> id(decode_msg_deploy(Bin, TrUserData), TrUserData);
decode_msg_2_doit(fetch_task_log, Bin, TrUserData) -> id(decode_msg_fetch_task_log(Bin, TrUserData), TrUserData);
decode_msg_2_doit(invoke, Bin, TrUserData) -> id(decode_msg_invoke(Bin, TrUserData), TrUserData); decode_msg_2_doit(invoke, Bin, TrUserData) -> id(decode_msg_invoke(Bin, TrUserData), TrUserData);
decode_msg_2_doit(push_service_config, Bin, TrUserData) -> id(decode_msg_push_service_config(Bin, TrUserData), TrUserData); decode_msg_2_doit(service_config, Bin, TrUserData) -> id(decode_msg_service_config(Bin, TrUserData), TrUserData);
decode_msg_2_doit(data, Bin, TrUserData) -> id(decode_msg_data(Bin, TrUserData), TrUserData); decode_msg_2_doit(data, Bin, TrUserData) -> id(decode_msg_data(Bin, TrUserData), TrUserData);
decode_msg_2_doit(ping, Bin, TrUserData) -> id(decode_msg_ping(Bin, TrUserData), TrUserData); decode_msg_2_doit(ping, Bin, TrUserData) -> id(decode_msg_ping(Bin, TrUserData), TrUserData);
decode_msg_2_doit(service_inform, Bin, TrUserData) -> id(decode_msg_service_inform(Bin, TrUserData), TrUserData); decode_msg_2_doit(service_inform, Bin, TrUserData) -> id(decode_msg_service_inform(Bin, TrUserData), TrUserData);
@ -964,63 +946,63 @@ skip_32_pub(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_rea
skip_64_pub(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_pub(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). skip_64_pub(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_pub(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
decode_msg_async_call_reply(Bin, TrUserData) -> dfp_read_field_def_async_call_reply(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). decode_msg_push_reply(Bin, TrUserData) -> dfp_read_field_def_push_reply(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
dfp_read_field_def_async_call_reply(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_code(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_push_reply(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_code(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_async_call_reply(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_result(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_push_reply(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_result(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_async_call_reply(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_async_call_reply_message(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_push_reply(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_reply_message(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_async_call_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #async_call_reply{code = F@_1, result = F@_2, message = F@_3}; dfp_read_field_def_push_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_reply{code = F@_1, result = F@_2, message = F@_3};
dfp_read_field_def_async_call_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_async_call_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_push_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_push_reply(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
dg_read_field_def_async_call_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_async_call_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_push_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_push_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
dg_read_field_def_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
Key = X bsl N + Acc, Key = X bsl N + Acc,
case Key of case Key of
8 -> d_field_async_call_reply_code(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 8 -> d_field_push_reply_code(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
18 -> d_field_async_call_reply_result(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_push_reply_result(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
26 -> d_field_async_call_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_push_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
_ -> _ ->
case Key band 7 of case Key band 7 of
0 -> skip_varint_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 0 -> skip_varint_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
1 -> skip_64_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
2 -> skip_length_delimited_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
3 -> skip_group_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
5 -> skip_32_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) 5 -> skip_32_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
end end
end; end;
dg_read_field_def_async_call_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #async_call_reply{code = F@_1, result = F@_2, message = F@_3}. dg_read_field_def_push_reply(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_reply{code = F@_1, result = F@_2, message = F@_3}.
d_field_async_call_reply_code(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_code(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_push_reply_code(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_code(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_async_call_reply_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> d_field_push_reply_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). dfp_read_field_def_push_reply(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
d_field_async_call_reply_result(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_result(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_push_reply_result(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_result(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_async_call_reply_result(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> d_field_push_reply_result(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
d_field_async_call_reply_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_async_call_reply_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_push_reply_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_reply_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_async_call_reply_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> d_field_push_reply_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
skip_varint_async_call_reply(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); skip_varint_push_reply(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
skip_varint_async_call_reply(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_varint_push_reply(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
skip_length_delimited_async_call_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_async_call_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_push_reply(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_push_reply(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
skip_length_delimited_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> skip_length_delimited_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
Length = X bsl N + Acc, Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest, <<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_async_call_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_push_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
skip_group_async_call_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> skip_group_push_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
{_, Rest} = read_group(Bin, FNum), {_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_async_call_reply(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_push_reply(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
skip_32_async_call_reply(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_32_push_reply(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
skip_64_async_call_reply(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_async_call_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_64_push_reply(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_reply(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
decode_msg_deploy(Bin, TrUserData) -> dfp_read_field_def_deploy(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). decode_msg_deploy(Bin, TrUserData) -> dfp_read_field_def_deploy(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
@ -1080,50 +1062,6 @@ skip_32_deploy(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -
skip_64_deploy(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_deploy(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_64_deploy(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_deploy(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
decode_msg_fetch_task_log(Bin, TrUserData) -> dfp_read_field_def_fetch_task_log(Bin, 0, 0, 0, id(0, TrUserData), TrUserData).
dfp_read_field_def_fetch_task_log(<<8, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_fetch_task_log_task_id(Rest, Z1, Z2, F, F@_1, TrUserData);
dfp_read_field_def_fetch_task_log(<<>>, 0, 0, _, F@_1, _) -> #fetch_task_log{task_id = F@_1};
dfp_read_field_def_fetch_task_log(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_fetch_task_log(Other, Z1, Z2, F, F@_1, TrUserData).
dg_read_field_def_fetch_task_log(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_fetch_task_log(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData);
dg_read_field_def_fetch_task_log(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> d_field_fetch_task_log_task_id(Rest, 0, 0, 0, F@_1, TrUserData);
_ ->
case Key band 7 of
0 -> skip_varint_fetch_task_log(Rest, 0, 0, Key bsr 3, F@_1, TrUserData);
1 -> skip_64_fetch_task_log(Rest, 0, 0, Key bsr 3, F@_1, TrUserData);
2 -> skip_length_delimited_fetch_task_log(Rest, 0, 0, Key bsr 3, F@_1, TrUserData);
3 -> skip_group_fetch_task_log(Rest, 0, 0, Key bsr 3, F@_1, TrUserData);
5 -> skip_32_fetch_task_log(Rest, 0, 0, Key bsr 3, F@_1, TrUserData)
end
end;
dg_read_field_def_fetch_task_log(<<>>, 0, 0, _, F@_1, _) -> #fetch_task_log{task_id = F@_1}.
d_field_fetch_task_log_task_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_fetch_task_log_task_id(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData);
d_field_fetch_task_log_task_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
dfp_read_field_def_fetch_task_log(RestF, 0, 0, F, NewFValue, TrUserData).
skip_varint_fetch_task_log(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_fetch_task_log(Rest, Z1, Z2, F, F@_1, TrUserData);
skip_varint_fetch_task_log(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_fetch_task_log(Rest, Z1, Z2, F, F@_1, TrUserData).
skip_length_delimited_fetch_task_log(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> skip_length_delimited_fetch_task_log(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData);
skip_length_delimited_fetch_task_log(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_fetch_task_log(Rest2, 0, 0, F, F@_1, TrUserData).
skip_group_fetch_task_log(Bin, _, Z2, FNum, F@_1, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_fetch_task_log(Rest, 0, Z2, FNum, F@_1, TrUserData).
skip_32_fetch_task_log(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_fetch_task_log(Rest, Z1, Z2, F, F@_1, TrUserData).
skip_64_fetch_task_log(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_fetch_task_log(Rest, Z1, Z2, F, F@_1, TrUserData).
decode_msg_invoke(Bin, TrUserData) -> dfp_read_field_def_invoke(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). decode_msg_invoke(Bin, TrUserData) -> dfp_read_field_def_invoke(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData).
dfp_read_field_def_invoke(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_invoke_service_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_invoke(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_invoke_service_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
@ -1182,63 +1120,63 @@ skip_32_invoke(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -
skip_64_invoke(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_invoke(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_64_invoke(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_invoke(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
decode_msg_push_service_config(Bin, TrUserData) -> dfp_read_field_def_push_service_config(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). decode_msg_service_config(Bin, TrUserData) -> dfp_read_field_def_service_config(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData).
dfp_read_field_def_push_service_config(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_service_config_service_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_service_config(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_service_config_service_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_push_service_config(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_service_config_config_json(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_service_config(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_service_config_config_json(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_push_service_config(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_push_service_config_timeout(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_service_config(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_service_config_timeout(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_push_service_config(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_service_config{service_id = F@_1, config_json = F@_2, timeout = F@_3}; dfp_read_field_def_service_config(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #service_config{service_id = F@_1, config_json = F@_2, timeout = F@_3};
dfp_read_field_def_push_service_config(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_push_service_config(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_service_config(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_service_config(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
dg_read_field_def_push_service_config(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_push_service_config(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_service_config(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_service_config(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
dg_read_field_def_push_service_config(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_service_config(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
Key = X bsl N + Acc, Key = X bsl N + Acc,
case Key of case Key of
10 -> d_field_push_service_config_service_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 10 -> d_field_service_config_service_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
18 -> d_field_push_service_config_config_json(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_service_config_config_json(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
24 -> d_field_push_service_config_timeout(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 24 -> d_field_service_config_timeout(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
_ -> _ ->
case Key band 7 of case Key band 7 of
0 -> skip_varint_push_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 0 -> skip_varint_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
1 -> skip_64_push_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
2 -> skip_length_delimited_push_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
3 -> skip_group_push_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData);
5 -> skip_32_push_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) 5 -> skip_32_service_config(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
end end
end; end;
dg_read_field_def_push_service_config(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #push_service_config{service_id = F@_1, config_json = F@_2, timeout = F@_3}. dg_read_field_def_service_config(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #service_config{service_id = F@_1, config_json = F@_2, timeout = F@_3}.
d_field_push_service_config_service_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_service_config_service_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_service_config_service_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_service_config_service_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_push_service_config_service_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> d_field_service_config_service_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_push_service_config(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). dfp_read_field_def_service_config(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
d_field_push_service_config_config_json(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_service_config_config_json(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_service_config_config_json(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_service_config_config_json(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_push_service_config_config_json(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> d_field_service_config_config_json(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_push_service_config(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). dfp_read_field_def_service_config(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
d_field_push_service_config_timeout(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_push_service_config_timeout(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_service_config_timeout(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_service_config_timeout(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_push_service_config_timeout(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> d_field_service_config_timeout(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest}, {NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
dfp_read_field_def_push_service_config(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). dfp_read_field_def_service_config(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
skip_varint_push_service_config(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_push_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); skip_varint_service_config(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
skip_varint_push_service_config(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_varint_service_config(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
skip_length_delimited_push_service_config(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_push_service_config(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_service_config(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_service_config(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
skip_length_delimited_push_service_config(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> skip_length_delimited_service_config(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
Length = X bsl N + Acc, Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest, <<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_push_service_config(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_service_config(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
skip_group_push_service_config(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> skip_group_service_config(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
{_, Rest} = read_group(Bin, FNum), {_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_push_service_config(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_service_config(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
skip_32_push_service_config(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_32_service_config(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
skip_64_push_service_config(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_push_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). skip_64_service_config(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_service_config(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
decode_msg_data(Bin, TrUserData) -> dfp_read_field_def_data(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). decode_msg_data(Bin, TrUserData) -> dfp_read_field_def_data(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
@ -1710,11 +1648,10 @@ merge_msgs(Prev, New, MsgName, Opts) ->
auth_request -> merge_msg_auth_request(Prev, New, TrUserData); auth_request -> merge_msg_auth_request(Prev, New, TrUserData);
auth_reply -> merge_msg_auth_reply(Prev, New, TrUserData); auth_reply -> merge_msg_auth_reply(Prev, New, TrUserData);
pub -> merge_msg_pub(Prev, New, TrUserData); pub -> merge_msg_pub(Prev, New, TrUserData);
async_call_reply -> merge_msg_async_call_reply(Prev, New, TrUserData); push_reply -> merge_msg_push_reply(Prev, New, TrUserData);
deploy -> merge_msg_deploy(Prev, New, TrUserData); deploy -> merge_msg_deploy(Prev, New, TrUserData);
fetch_task_log -> merge_msg_fetch_task_log(Prev, New, TrUserData);
invoke -> merge_msg_invoke(Prev, New, TrUserData); invoke -> merge_msg_invoke(Prev, New, TrUserData);
push_service_config -> merge_msg_push_service_config(Prev, New, TrUserData); service_config -> merge_msg_service_config(Prev, New, TrUserData);
data -> merge_msg_data(Prev, New, TrUserData); data -> merge_msg_data(Prev, New, TrUserData);
ping -> merge_msg_ping(Prev, New, TrUserData); ping -> merge_msg_ping(Prev, New, TrUserData);
service_inform -> merge_msg_service_inform(Prev, New, TrUserData); service_inform -> merge_msg_service_inform(Prev, New, TrUserData);
@ -1766,20 +1703,20 @@ merge_msg_pub(#pub{topic = PFtopic, content = PFcontent}, #pub{topic = NFtopic,
true -> NFcontent true -> NFcontent
end}. end}.
-compile({nowarn_unused_function,merge_msg_async_call_reply/3}). -compile({nowarn_unused_function,merge_msg_push_reply/3}).
merge_msg_async_call_reply(#async_call_reply{code = PFcode, result = PFresult, message = PFmessage}, #async_call_reply{code = NFcode, result = NFresult, message = NFmessage}, _) -> merge_msg_push_reply(#push_reply{code = PFcode, result = PFresult, message = PFmessage}, #push_reply{code = NFcode, result = NFresult, message = NFmessage}, _) ->
#async_call_reply{code = #push_reply{code =
if NFcode =:= undefined -> PFcode; if NFcode =:= undefined -> PFcode;
true -> NFcode true -> NFcode
end, end,
result = result =
if NFresult =:= undefined -> PFresult; if NFresult =:= undefined -> PFresult;
true -> NFresult true -> NFresult
end, end,
message = message =
if NFmessage =:= undefined -> PFmessage; if NFmessage =:= undefined -> PFmessage;
true -> NFmessage true -> NFmessage
end}. end}.
-compile({nowarn_unused_function,merge_msg_deploy/3}). -compile({nowarn_unused_function,merge_msg_deploy/3}).
merge_msg_deploy(#deploy{task_id = PFtask_id, service_id = PFservice_id, tar_url = PFtar_url}, #deploy{task_id = NFtask_id, service_id = NFservice_id, tar_url = NFtar_url}, _) -> merge_msg_deploy(#deploy{task_id = PFtask_id, service_id = PFservice_id, tar_url = PFtar_url}, #deploy{task_id = NFtask_id, service_id = NFservice_id, tar_url = NFtar_url}, _) ->
@ -1796,13 +1733,6 @@ merge_msg_deploy(#deploy{task_id = PFtask_id, service_id = PFservice_id, tar_url
true -> NFtar_url true -> NFtar_url
end}. end}.
-compile({nowarn_unused_function,merge_msg_fetch_task_log/3}).
merge_msg_fetch_task_log(#fetch_task_log{task_id = PFtask_id}, #fetch_task_log{task_id = NFtask_id}, _) ->
#fetch_task_log{task_id =
if NFtask_id =:= undefined -> PFtask_id;
true -> NFtask_id
end}.
-compile({nowarn_unused_function,merge_msg_invoke/3}). -compile({nowarn_unused_function,merge_msg_invoke/3}).
merge_msg_invoke(#invoke{service_id = PFservice_id, payload = PFpayload, timeout = PFtimeout}, #invoke{service_id = NFservice_id, payload = NFpayload, timeout = NFtimeout}, _) -> merge_msg_invoke(#invoke{service_id = PFservice_id, payload = PFpayload, timeout = PFtimeout}, #invoke{service_id = NFservice_id, payload = NFpayload, timeout = NFtimeout}, _) ->
#invoke{service_id = #invoke{service_id =
@ -1818,20 +1748,20 @@ merge_msg_invoke(#invoke{service_id = PFservice_id, payload = PFpayload, timeout
true -> NFtimeout true -> NFtimeout
end}. end}.
-compile({nowarn_unused_function,merge_msg_push_service_config/3}). -compile({nowarn_unused_function,merge_msg_service_config/3}).
merge_msg_push_service_config(#push_service_config{service_id = PFservice_id, config_json = PFconfig_json, timeout = PFtimeout}, #push_service_config{service_id = NFservice_id, config_json = NFconfig_json, timeout = NFtimeout}, _) -> merge_msg_service_config(#service_config{service_id = PFservice_id, config_json = PFconfig_json, timeout = PFtimeout}, #service_config{service_id = NFservice_id, config_json = NFconfig_json, timeout = NFtimeout}, _) ->
#push_service_config{service_id = #service_config{service_id =
if NFservice_id =:= undefined -> PFservice_id; if NFservice_id =:= undefined -> PFservice_id;
true -> NFservice_id true -> NFservice_id
end, end,
config_json = config_json =
if NFconfig_json =:= undefined -> PFconfig_json; if NFconfig_json =:= undefined -> PFconfig_json;
true -> NFconfig_json true -> NFconfig_json
end, end,
timeout = timeout =
if NFtimeout =:= undefined -> PFtimeout; if NFtimeout =:= undefined -> PFtimeout;
true -> NFtimeout true -> NFtimeout
end}. end}.
-compile({nowarn_unused_function,merge_msg_data/3}). -compile({nowarn_unused_function,merge_msg_data/3}).
merge_msg_data(#data{service_id = PFservice_id, device_uuid = PFdevice_uuid, metric = PFmetric}, #data{service_id = NFservice_id, device_uuid = NFdevice_uuid, metric = NFmetric}, _) -> merge_msg_data(#data{service_id = PFservice_id, device_uuid = PFdevice_uuid, metric = PFmetric}, #data{service_id = NFservice_id, device_uuid = NFdevice_uuid, metric = NFmetric}, _) ->
@ -1958,11 +1888,10 @@ verify_msg(Msg, MsgName, Opts) ->
auth_request -> v_msg_auth_request(Msg, [MsgName], TrUserData); auth_request -> v_msg_auth_request(Msg, [MsgName], TrUserData);
auth_reply -> v_msg_auth_reply(Msg, [MsgName], TrUserData); auth_reply -> v_msg_auth_reply(Msg, [MsgName], TrUserData);
pub -> v_msg_pub(Msg, [MsgName], TrUserData); pub -> v_msg_pub(Msg, [MsgName], TrUserData);
async_call_reply -> v_msg_async_call_reply(Msg, [MsgName], TrUserData); push_reply -> v_msg_push_reply(Msg, [MsgName], TrUserData);
deploy -> v_msg_deploy(Msg, [MsgName], TrUserData); deploy -> v_msg_deploy(Msg, [MsgName], TrUserData);
fetch_task_log -> v_msg_fetch_task_log(Msg, [MsgName], TrUserData);
invoke -> v_msg_invoke(Msg, [MsgName], TrUserData); invoke -> v_msg_invoke(Msg, [MsgName], TrUserData);
push_service_config -> v_msg_push_service_config(Msg, [MsgName], TrUserData); service_config -> v_msg_service_config(Msg, [MsgName], TrUserData);
data -> v_msg_data(Msg, [MsgName], TrUserData); data -> v_msg_data(Msg, [MsgName], TrUserData);
ping -> v_msg_ping(Msg, [MsgName], TrUserData); ping -> v_msg_ping(Msg, [MsgName], TrUserData);
service_inform -> v_msg_service_inform(Msg, [MsgName], TrUserData); service_inform -> v_msg_service_inform(Msg, [MsgName], TrUserData);
@ -2016,9 +1945,9 @@ v_msg_pub(#pub{topic = F1, content = F2}, Path, TrUserData) ->
ok; ok;
v_msg_pub(X, Path, _TrUserData) -> mk_type_error({expected_msg, pub}, X, Path). v_msg_pub(X, Path, _TrUserData) -> mk_type_error({expected_msg, pub}, X, Path).
-compile({nowarn_unused_function,v_msg_async_call_reply/3}). -compile({nowarn_unused_function,v_msg_push_reply/3}).
-dialyzer({nowarn_function,v_msg_async_call_reply/3}). -dialyzer({nowarn_function,v_msg_push_reply/3}).
v_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Path, TrUserData) -> v_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Path, TrUserData) ->
if F1 == undefined -> ok; if F1 == undefined -> ok;
true -> v_type_uint32(F1, [code | Path], TrUserData) true -> v_type_uint32(F1, [code | Path], TrUserData)
end, end,
@ -2029,7 +1958,7 @@ v_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3},
true -> v_type_string(F3, [message | Path], TrUserData) true -> v_type_string(F3, [message | Path], TrUserData)
end, end,
ok; ok;
v_msg_async_call_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, async_call_reply}, X, Path). v_msg_push_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, push_reply}, X, Path).
-compile({nowarn_unused_function,v_msg_deploy/3}). -compile({nowarn_unused_function,v_msg_deploy/3}).
-dialyzer({nowarn_function,v_msg_deploy/3}). -dialyzer({nowarn_function,v_msg_deploy/3}).
@ -2046,15 +1975,6 @@ v_msg_deploy(#deploy{task_id = F1, service_id = F2, tar_url = F3}, Path, TrUserD
ok; ok;
v_msg_deploy(X, Path, _TrUserData) -> mk_type_error({expected_msg, deploy}, X, Path). v_msg_deploy(X, Path, _TrUserData) -> mk_type_error({expected_msg, deploy}, X, Path).
-compile({nowarn_unused_function,v_msg_fetch_task_log/3}).
-dialyzer({nowarn_function,v_msg_fetch_task_log/3}).
v_msg_fetch_task_log(#fetch_task_log{task_id = F1}, Path, TrUserData) ->
if F1 == undefined -> ok;
true -> v_type_uint32(F1, [task_id | Path], TrUserData)
end,
ok;
v_msg_fetch_task_log(X, Path, _TrUserData) -> mk_type_error({expected_msg, fetch_task_log}, X, Path).
-compile({nowarn_unused_function,v_msg_invoke/3}). -compile({nowarn_unused_function,v_msg_invoke/3}).
-dialyzer({nowarn_function,v_msg_invoke/3}). -dialyzer({nowarn_function,v_msg_invoke/3}).
v_msg_invoke(#invoke{service_id = F1, payload = F2, timeout = F3}, Path, TrUserData) -> v_msg_invoke(#invoke{service_id = F1, payload = F2, timeout = F3}, Path, TrUserData) ->
@ -2070,9 +1990,9 @@ v_msg_invoke(#invoke{service_id = F1, payload = F2, timeout = F3}, Path, TrUserD
ok; ok;
v_msg_invoke(X, Path, _TrUserData) -> mk_type_error({expected_msg, invoke}, X, Path). v_msg_invoke(X, Path, _TrUserData) -> mk_type_error({expected_msg, invoke}, X, Path).
-compile({nowarn_unused_function,v_msg_push_service_config/3}). -compile({nowarn_unused_function,v_msg_service_config/3}).
-dialyzer({nowarn_function,v_msg_push_service_config/3}). -dialyzer({nowarn_function,v_msg_service_config/3}).
v_msg_push_service_config(#push_service_config{service_id = F1, config_json = F2, timeout = F3}, Path, TrUserData) -> v_msg_service_config(#service_config{service_id = F1, config_json = F2, timeout = F3}, Path, TrUserData) ->
if F1 == undefined -> ok; if F1 == undefined -> ok;
true -> v_type_string(F1, [service_id | Path], TrUserData) true -> v_type_string(F1, [service_id | Path], TrUserData)
end, end,
@ -2083,7 +2003,7 @@ v_msg_push_service_config(#push_service_config{service_id = F1, config_json = F2
true -> v_type_uint32(F3, [timeout | Path], TrUserData) true -> v_type_uint32(F3, [timeout | Path], TrUserData)
end, end,
ok; ok;
v_msg_push_service_config(X, Path, _TrUserData) -> mk_type_error({expected_msg, push_service_config}, X, Path). v_msg_service_config(X, Path, _TrUserData) -> mk_type_error({expected_msg, service_config}, X, Path).
-compile({nowarn_unused_function,v_msg_data/3}). -compile({nowarn_unused_function,v_msg_data/3}).
-dialyzer({nowarn_function,v_msg_data/3}). -dialyzer({nowarn_function,v_msg_data/3}).
@ -2262,7 +2182,7 @@ get_msg_defs() ->
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}]}, #field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}]},
{{msg, auth_reply}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]}, {{msg, auth_reply}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
{{msg, pub}, [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]}, {{msg, pub}, [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
{{msg, async_call_reply}, {{msg, push_reply},
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}, #field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
@ -2270,12 +2190,11 @@ get_msg_defs() ->
[#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
#field{name = service_id, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = service_id, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = tar_url, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}, #field{name = tar_url, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
{{msg, fetch_task_log}, [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}]},
{{msg, invoke}, {{msg, invoke},
[#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = payload, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = payload, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]}, #field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]},
{{msg, push_service_config}, {{msg, service_config},
[#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = config_json, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = config_json, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]}, #field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]},
@ -2308,13 +2227,13 @@ get_msg_defs() ->
#field{name = params, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}]. #field{name = params, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}].
get_msg_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, push_service_config, data, ping, service_inform, event]. get_msg_names() -> [auth_request, auth_reply, pub, push_reply, deploy, invoke, service_config, data, ping, service_inform, event].
get_group_names() -> []. get_group_names() -> [].
get_msg_or_group_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, push_service_config, data, ping, service_inform, event]. get_msg_or_group_names() -> [auth_request, auth_reply, pub, push_reply, deploy, invoke, service_config, data, ping, service_inform, event].
get_enum_names() -> []. get_enum_names() -> [].
@ -2339,7 +2258,7 @@ find_msg_def(auth_request) ->
#field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}]; #field{name = timestamp, fnum = 6, rnum = 6, type = uint32, occurrence = optional, opts = []}];
find_msg_def(auth_reply) -> [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]; find_msg_def(auth_reply) -> [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = message, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
find_msg_def(pub) -> [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]; find_msg_def(pub) -> [#field{name = topic, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = content, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}];
find_msg_def(async_call_reply) -> find_msg_def(push_reply) ->
[#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, [#field{name = code, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
#field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = result, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]; #field{name = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
@ -2347,12 +2266,11 @@ find_msg_def(deploy) ->
[#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []},
#field{name = service_id, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = service_id, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = tar_url, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]; #field{name = tar_url, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
find_msg_def(fetch_task_log) -> [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}];
find_msg_def(invoke) -> find_msg_def(invoke) ->
[#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = payload, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = payload, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]; #field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}];
find_msg_def(push_service_config) -> find_msg_def(service_config) ->
[#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = service_id, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = config_json, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = config_json, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}]; #field{name = timeout, fnum = 3, rnum = 4, type = uint32, occurrence = optional, opts = []}];
@ -2444,11 +2362,10 @@ service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S
fqbin_to_msg_name(<<"AuthRequest">>) -> auth_request; fqbin_to_msg_name(<<"AuthRequest">>) -> auth_request;
fqbin_to_msg_name(<<"AuthReply">>) -> auth_reply; fqbin_to_msg_name(<<"AuthReply">>) -> auth_reply;
fqbin_to_msg_name(<<"Pub">>) -> pub; fqbin_to_msg_name(<<"Pub">>) -> pub;
fqbin_to_msg_name(<<"AsyncCallReply">>) -> async_call_reply; fqbin_to_msg_name(<<"PushReply">>) -> push_reply;
fqbin_to_msg_name(<<"Deploy">>) -> deploy; fqbin_to_msg_name(<<"Deploy">>) -> deploy;
fqbin_to_msg_name(<<"FetchTaskLog">>) -> fetch_task_log;
fqbin_to_msg_name(<<"Invoke">>) -> invoke; fqbin_to_msg_name(<<"Invoke">>) -> invoke;
fqbin_to_msg_name(<<"PushServiceConfig">>) -> push_service_config; fqbin_to_msg_name(<<"ServiceConfig">>) -> service_config;
fqbin_to_msg_name(<<"Data">>) -> data; fqbin_to_msg_name(<<"Data">>) -> data;
fqbin_to_msg_name(<<"Ping">>) -> ping; fqbin_to_msg_name(<<"Ping">>) -> ping;
fqbin_to_msg_name(<<"ServiceInform">>) -> service_inform; fqbin_to_msg_name(<<"ServiceInform">>) -> service_inform;
@ -2459,11 +2376,10 @@ fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin(auth_request) -> <<"AuthRequest">>; msg_name_to_fqbin(auth_request) -> <<"AuthRequest">>;
msg_name_to_fqbin(auth_reply) -> <<"AuthReply">>; msg_name_to_fqbin(auth_reply) -> <<"AuthReply">>;
msg_name_to_fqbin(pub) -> <<"Pub">>; msg_name_to_fqbin(pub) -> <<"Pub">>;
msg_name_to_fqbin(async_call_reply) -> <<"AsyncCallReply">>; msg_name_to_fqbin(push_reply) -> <<"PushReply">>;
msg_name_to_fqbin(deploy) -> <<"Deploy">>; msg_name_to_fqbin(deploy) -> <<"Deploy">>;
msg_name_to_fqbin(fetch_task_log) -> <<"FetchTaskLog">>;
msg_name_to_fqbin(invoke) -> <<"Invoke">>; msg_name_to_fqbin(invoke) -> <<"Invoke">>;
msg_name_to_fqbin(push_service_config) -> <<"PushServiceConfig">>; msg_name_to_fqbin(service_config) -> <<"ServiceConfig">>;
msg_name_to_fqbin(data) -> <<"Data">>; msg_name_to_fqbin(data) -> <<"Data">>;
msg_name_to_fqbin(ping) -> <<"Ping">>; msg_name_to_fqbin(ping) -> <<"Ping">>;
msg_name_to_fqbin(service_inform) -> <<"ServiceInform">>; msg_name_to_fqbin(service_inform) -> <<"ServiceInform">>;
@ -2506,7 +2422,7 @@ get_all_source_basenames() -> ["message_pb.proto"].
get_all_proto_names() -> ["message_pb"]. get_all_proto_names() -> ["message_pb"].
get_msg_containment("message_pb") -> [async_call_reply, auth_reply, auth_request, data, deploy, event, fetch_task_log, invoke, ping, pub, push_service_config, service_inform]; get_msg_containment("message_pb") -> [auth_reply, auth_request, data, deploy, event, invoke, ping, pub, push_reply, service_config, service_inform];
get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
@ -2531,12 +2447,11 @@ get_proto_by_msg_name_as_fqbin(<<"Pub">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"Event">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"Event">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"AuthRequest">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"AuthRequest">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"Invoke">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"Invoke">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"PushServiceConfig">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"ServiceConfig">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"Ping">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"Ping">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"FetchTaskLog">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"PushReply">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"Deploy">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"Deploy">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"AuthReply">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"AuthReply">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"AsyncCallReply">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(<<"ServiceInform">>) -> "message_pb"; get_proto_by_msg_name_as_fqbin(<<"ServiceInform">>) -> "message_pb";
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).

View File

@ -2,10 +2,6 @@
{efka, [ {efka, [
{root_dir, "/tmp/efka/"}, {root_dir, "/tmp/efka/"},
{tcp_server, [
{port, 18080}
]},
{tls_server, [ {tls_server, [
{host, "localhost"}, {host, "localhost"},
{port, 443} {port, 443}

View File

@ -2,9 +2,5 @@
-setcookie efka_cookie -setcookie efka_cookie
-mnesia dir '"/usr/local/var/mnesia/efka"'
-mnesia dump_log_write_threshold 5000
-mnesia dc_dump_limit 40
+K true +K true
+A 5 +A 5

View File

@ -24,7 +24,7 @@ message Pub {
///// /////
message AsyncCallReply { message PushReply {
// 0: 1: // 0: 1:
uint32 code = 1; uint32 code = 1;
string result = 2; string result = 2;
@ -38,12 +38,7 @@ message Deploy {
string tar_url = 3; string tar_url = 3;
} }
// task的logs // ,
message FetchTaskLog {
uint32 task_id = 1;
}
// , ;
message Invoke { message Invoke {
string service_id = 1; string service_id = 1;
string payload = 2; string payload = 2;
@ -51,7 +46,7 @@ message Invoke {
} }
// //
message PushServiceConfig { message ServiceConfig {
string service_id = 1; string service_id = 1;
string config_json = 2; string config_json = 2;
uint32 timeout = 3; uint32 timeout = 3;