This commit is contained in:
anlicheng 2025-05-09 22:35:21 +08:00
parent d66ab5a5ca
commit 29e3e6ef50
6 changed files with 133 additions and 129 deletions

View File

@ -19,8 +19,8 @@
-define(PACKET_COMMAND, 16#04).
%%
-define(PACKET_PUSH, 16#05).
-define(PACKET_PUSH_REPLY, 16#06).
-define(PACKET_ASYNC_CALL, 16#05).
-define(PACKET_ASYNC_CALL_REPLY, 16#06).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%

View File

@ -35,9 +35,9 @@
}).
-endif.
-ifndef('PUSH_REPLY_PB_H').
-define('PUSH_REPLY_PB_H', true).
-record(push_reply,
-ifndef('ASYNC_CALL_REPLY_PB_H').
-define('ASYNC_CALL_REPLY_PB_H', true).
-record(async_call_reply,
{code = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
result = <<>> :: unicode:chardata() | undefined, % = 2, optional
message = <<>> :: unicode:chardata() | undefined % = 3, optional

View File

@ -168,7 +168,8 @@ 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) ->
case Reply of
ok ->
efka_transport:auth_request(TransportPid, 5000),
AuthBin = auth_request(),
efka_transport:auth_request(TransportPid, AuthBin, 5000),
{noreply, State#state{status = ?STATE_AUTH}};
{error, Reason} ->
lager:debug("[efka_agent] connect failed, error: ~p, pid: ~p", [Reason, TransportPid]),
@ -225,11 +226,11 @@ handle_info({server_push, PacketId, <<?PUSH_DEPLOY:8, DeployBin/binary>>}, State
%% efka_inetd收到消息后就立即返回了
Reply = case efka_inetd:deploy(TaskId, ServiceId, TarUrl) of
ok ->
#push_reply{code = 1, message = <<"">>};
#async_call_reply{code = 1, message = <<"">>};
{error, Reason} when is_binary(Reason) ->
#push_reply{code = 0, message = Reason}
#async_call_reply{code = 0, message = Reason}
end,
is_pid(TransportPid) andalso efka_transport:push_response(TransportPid, PacketId, message_pb:encode_msg(Reply)),
is_pid(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)),
{noreply, State};
@ -239,8 +240,8 @@ handle_info({server_push, PacketId, <<?PUSH_SERVICE_CONFIG:8, ConfigBin/binary>>
case efka_service:get_pid(ServiceId) of
undefined ->
Reply = #push_reply{code = 0, message = <<"service not run">>},
is_pid(TransportPid) andalso efka_transport:push_response(TransportPid, PacketId, message_pb:encode_msg(Reply)),
Reply = #async_call_reply{code = 0, message = <<"service not run">>},
is_pid(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)),
{noreply, State};
ServicePid when is_pid(ServicePid) ->
Ref = make_ref(),
@ -258,8 +259,8 @@ handle_info({server_push, PacketId, <<?PUSH_INVOKE:8, InvokeBin/binary>>}, State
%%
case efka_service:get_pid(ServiceId) of
undefined ->
Reply = #push_reply{code = 0, message = <<"micro_service not run">>, result = <<>>},
safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
Reply = #async_call_reply{code = 0, message = <<"micro_service not run">>, result = <<>>},
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State};
ServicePid when is_pid(ServicePid) ->
Ref = make_ref(),
@ -277,11 +278,11 @@ handle_info({server_push, PacketId, <<?PUSH_TASK_LOG:8, TaskLogBin/binary>>}, St
Reply = case length(Logs) > 0 of
true ->
Result = iolist_to_binary(jiffy:encode(Logs, [force_utf8])),
#push_reply{code = 1, result = Result};
#async_call_reply{code = 1, result = Result};
false ->
#push_reply{code = 1, result = <<"[]">>}
#async_call_reply{code = 1, result = <<"[]">>}
end,
safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State};
%%
@ -291,7 +292,8 @@ handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transpor
{noreply, State};
{1, ?STATE_DENIED} ->
%% ,
efka_transport:auth_request(TransportPid, 5000),
AuthRequestBin = auth_request(),
efka_transport:auth_request(TransportPid, AuthRequestBin, 5000),
{noreply, State#state{status = ?STATE_AUTH}};
{0, _} ->
%%
@ -314,11 +316,11 @@ handle_info({service_reply, Ref, EmsReply}, State = #state{inflight = Inflight})
{PacketId, NInflight} ->
Reply = case EmsReply of
ok ->
#push_reply{code = 1, message = <<"">>, result = <<>>};
#async_call_reply{code = 1, message = <<"">>, result = <<>>};
{error, Reason} ->
#push_reply{code = 0, message = Reason}
#async_call_reply{code = 0, message = Reason}
end,
safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State#state{inflight = NInflight}}
end;
@ -329,8 +331,8 @@ handle_info({timeout, _, {request_timeout, Ref}}, State = #state{inflight = Infl
error ->
{noreply, State};
{PacketId, NInflight} ->
Reply = #push_reply{code = 0, message = <<"reqeust timeout">>, result = <<>>},
safe_push_response(PacketId, message_pb:encode_msg(Reply), State),
Reply = #async_call_reply{code = 0, message = <<"reqeust timeout">>, result = <<>>},
safe_async_call_reply(PacketId, message_pb:encode_msg(Reply), State),
{noreply, State#state{inflight = NInflight}}
end;
@ -367,10 +369,10 @@ code_change(_OldVsn, State = #state{}, _Extra) ->
%%%===================================================================
%%
-spec safe_push_response(PacketId :: integer(), Reply :: binary(), State :: #state{}) -> no_return().
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:push_response(TransportPid, PacketId, Reply);
safe_push_response(_PacketId, _Reply, #state{}) ->
-spec safe_async_call_reply(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) ->
is_process_alive(TransportPid) andalso efka_transport:async_call_reply(TransportPid, PacketId, Reply);
safe_async_call_reply(_PacketId, _Reply, #state{}) ->
ok.
%%
@ -378,4 +380,20 @@ safe_push_response(_PacketId, _Reply, #state{}) ->
safe_send(Method, Packet, #state{status = ?STATE_ACTIVATED, transport_pid = TransportPid}) when is_pid(TransportPid) ->
efka_transport:send(TransportPid, Method, Packet);
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

@ -15,7 +15,7 @@
%% API
-export([start_link/3]).
-export([connect/1, auth_request/2, send/3, push_response/3, stop/1]).
-export([connect/1, auth_request/3, send/3, async_call_reply/3, stop/1]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@ -34,9 +34,9 @@
%%% API
%%%===================================================================
-spec auth_request(Pid :: pid(), Timeout :: integer()) -> no_return().
auth_request(Pid, Timeout) when is_pid(Pid), is_integer(Timeout) ->
gen_server:cast(Pid, {auth_request, Timeout}).
-spec auth_request(Pid :: pid(), AuthBin :: binary(), Timeout :: integer()) -> no_return().
auth_request(Pid, AuthBin, Timeout) when is_pid(Pid), is_binary(AuthBin), is_integer(Timeout) ->
gen_server:cast(Pid, {auth_request, AuthBin, Timeout}).
-spec connect(Pid :: pid()) -> no_return().
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) ->
gen_server:cast(Pid, {send, Method, Packet}).
-spec push_response(Pid :: pid(), PacketId :: integer(), Response :: binary()) -> no_return().
push_response(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) ->
gen_server:cast(Pid, {push_response, PacketId, Response}).
-spec async_call_reply(Pid :: pid(), PacketId :: integer(), Response :: binary()) -> no_return().
async_call_reply(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) ->
gen_server:cast(Pid, {async_call_reply, PacketId, Response}).
-spec stop(Pid :: pid()) -> ok.
stop(Pid) when is_pid(Pid) ->
@ -108,22 +108,8 @@ handle_cast(connect, State = #state{host = Host, port = Port, parent_pid = Paren
end;
%% auth校验
handle_cast({auth_request, Timeout}, State = #state{parent_pid = ParentPid, socket = Socket, packet_id = PacketId}) ->
{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>>),
handle_cast({auth_request, AuthRequestBin, Timeout}, State = #state{parent_pid = ParentPid, socket = Socket, packet_id = PacketId}) ->
ok = ssl:send(Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH, AuthRequestBin/binary>>),
%% auth返回的结果
receive
{ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ?METHOD_AUTH, ReplyBin/binary>>} ->
@ -135,12 +121,12 @@ handle_cast({auth_request, Timeout}, State = #state{parent_pid = ParentPid, sock
end;
handle_cast({send, Method, Packet}, State = #state{socket = Socket}) ->
ok = ssl:send(Socket, <<?PACKET_REQUEST, 0:32, Method, Packet/binary>>),
ok = ssl:send(Socket, <<?PACKET_REQUEST, Method:8, Packet/binary>>),
{noreply, State};
%% push的消息的回复
handle_cast({push_response, PacketId, Response}, State = #state{socket = Socket}) ->
ok = ssl:send(Socket, <<?PACKET_PUSH_REPLY, PacketId:32, Response/binary>>),
handle_cast({async_call_reply, PacketId, Response}, State = #state{socket = Socket}) ->
ok = ssl:send(Socket, <<?PACKET_ASYNC_CALL_REPLY, PacketId:32, Response/binary>>),
{noreply, State}.
%% @private
@ -150,17 +136,17 @@ handle_cast({push_response, PacketId, Response}, State = #state{socket = Socket}
{noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}).
%% packetId的是要求返回的0
handle_info({ssl, Socket, <<?PACKET_COMMAND, 0:32, CommandType:8, Command/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
handle_info({ssl, Socket, <<?PACKET_COMMAND, CommandType:8, Command/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
ParentPid ! {server_command, CommandType, Command},
{noreply, State};
handle_info({ssl, Socket, <<?PACKET_PUB, 0:32, PubBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
handle_info({ssl, Socket, <<?PACKET_PUB, PubBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
#pub{topic = Topic, content = Content} = message_pb:decode_msg(PubBin, pub),
ParentPid ! {server_pub, Topic, Content},
{noreply, State};
handle_info({ssl, Socket, <<?PACKET_PUSH, PacketId:32, PushBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
ParentPid ! {server_push, PacketId, PushBin},
handle_info({ssl, Socket, <<?PACKET_ASYNC_CALL, PacketId:32, AsyncCallBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
ParentPid ! {server_push, PacketId, AsyncCallBin},
{noreply, State};
handle_info({ssl_error, Socket, Reason}, State = #state{socket = Socket}) ->

View File

@ -61,7 +61,7 @@
-type pub() :: #pub{}.
-type push_reply() :: #push_reply{}.
-type async_call_reply() :: #async_call_reply{}.
-type deploy() :: #deploy{}.
@ -79,9 +79,9 @@
-type event() :: #event{}.
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'push_reply'/0, 'deploy'/0, 'fetch_task_log'/0, 'invoke'/0, 'service_config'/0, 'data'/0, 'ping'/0, 'service_inform'/0, 'event'/0]).
-type '$msg_name'() :: auth_request | auth_reply | pub | push_reply | deploy | fetch_task_log | invoke | service_config | data | ping | service_inform | event.
-type '$msg'() :: auth_request() | auth_reply() | pub() | push_reply() | deploy() | fetch_task_log() | invoke() | service_config() | data() | ping() | service_inform() | event().
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'async_call_reply'/0, 'deploy'/0, 'fetch_task_log'/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 | service_config | data | ping | service_inform | event.
-type '$msg'() :: auth_request() | auth_reply() | pub() | async_call_reply() | deploy() | fetch_task_log() | invoke() | service_config() | data() | ping() | service_inform() | event().
-export_type(['$msg_name'/0, '$msg'/0]).
-if(?OTP_RELEASE >= 24).
@ -111,7 +111,7 @@ encode_msg(Msg, MsgName, Opts) ->
auth_request -> encode_msg_auth_request(id(Msg, TrUserData), TrUserData);
auth_reply -> encode_msg_auth_reply(id(Msg, TrUserData), TrUserData);
pub -> encode_msg_pub(id(Msg, TrUserData), TrUserData);
push_reply -> encode_msg_push_reply(id(Msg, TrUserData), TrUserData);
async_call_reply -> encode_msg_async_call_reply(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);
@ -226,10 +226,10 @@ encode_msg_pub(#pub{topic = F1, content = F2}, Bin, TrUserData) ->
end
end.
encode_msg_push_reply(Msg, TrUserData) -> encode_msg_push_reply(Msg, <<>>, TrUserData).
encode_msg_async_call_reply(Msg, TrUserData) -> encode_msg_async_call_reply(Msg, <<>>, TrUserData).
encode_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
encode_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin;
true ->
begin
@ -778,7 +778,7 @@ 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_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(push_reply, Bin, TrUserData) -> id(decode_msg_push_reply(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(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);
@ -964,63 +964,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).
decode_msg_push_reply(Bin, TrUserData) -> dfp_read_field_def_push_reply(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), 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).
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_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_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_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_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).
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_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_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_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_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).
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_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, 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_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> d_field_push_reply_code(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_push_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
8 -> d_field_async_call_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);
26 -> d_field_async_call_reply_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
_ ->
case Key band 7 of
0 -> skip_varint_push_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_push_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_push_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
0 -> skip_varint_async_call_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);
2 -> skip_length_delimited_async_call_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);
5 -> skip_32_async_call_reply(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
end
end;
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}.
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}.
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_push_reply_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
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_async_call_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},
dfp_read_field_def_push_reply(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, NewFValue, 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_push_reply_result(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, 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_async_call_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,
dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, NewFValue, 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_push_reply_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, 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_async_call_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,
dfp_read_field_def_push_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData).
dfp_read_field_def_async_call_reply(RestF, 0, 0, F, F@_1, F@_2, NewFValue, 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_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_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_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_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_push_reply(<<0:1, X:7, Rest/binary>>, N, Acc, 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_async_call_reply(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_push_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
dfp_read_field_def_async_call_reply(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData).
skip_group_push_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
skip_group_async_call_reply(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_push_reply(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData).
dfp_read_field_def_async_call_reply(Rest, 0, Z2, FNum, 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_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_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).
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).
decode_msg_deploy(Bin, TrUserData) -> dfp_read_field_def_deploy(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
@ -1710,7 +1710,7 @@ merge_msgs(Prev, New, MsgName, Opts) ->
auth_request -> merge_msg_auth_request(Prev, New, TrUserData);
auth_reply -> merge_msg_auth_reply(Prev, New, TrUserData);
pub -> merge_msg_pub(Prev, New, TrUserData);
push_reply -> merge_msg_push_reply(Prev, New, TrUserData);
async_call_reply -> merge_msg_async_call_reply(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);
@ -1766,20 +1766,20 @@ merge_msg_pub(#pub{topic = PFtopic, content = PFcontent}, #pub{topic = NFtopic,
true -> NFcontent
end}.
-compile({nowarn_unused_function,merge_msg_push_reply/3}).
merge_msg_push_reply(#push_reply{code = PFcode, result = PFresult, message = PFmessage}, #push_reply{code = NFcode, result = NFresult, message = NFmessage}, _) ->
#push_reply{code =
if NFcode =:= undefined -> PFcode;
true -> NFcode
end,
result =
if NFresult =:= undefined -> PFresult;
true -> NFresult
end,
message =
if NFmessage =:= undefined -> PFmessage;
true -> NFmessage
end}.
-compile({nowarn_unused_function,merge_msg_async_call_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}, _) ->
#async_call_reply{code =
if NFcode =:= undefined -> PFcode;
true -> NFcode
end,
result =
if NFresult =:= undefined -> PFresult;
true -> NFresult
end,
message =
if NFmessage =:= undefined -> PFmessage;
true -> NFmessage
end}.
-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}, _) ->
@ -1958,7 +1958,7 @@ verify_msg(Msg, MsgName, Opts) ->
auth_request -> v_msg_auth_request(Msg, [MsgName], TrUserData);
auth_reply -> v_msg_auth_reply(Msg, [MsgName], TrUserData);
pub -> v_msg_pub(Msg, [MsgName], TrUserData);
push_reply -> v_msg_push_reply(Msg, [MsgName], TrUserData);
async_call_reply -> v_msg_async_call_reply(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);
@ -2016,9 +2016,9 @@ v_msg_pub(#pub{topic = F1, content = F2}, Path, TrUserData) ->
ok;
v_msg_pub(X, Path, _TrUserData) -> mk_type_error({expected_msg, pub}, X, Path).
-compile({nowarn_unused_function,v_msg_push_reply/3}).
-dialyzer({nowarn_function,v_msg_push_reply/3}).
v_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Path, TrUserData) ->
-compile({nowarn_unused_function,v_msg_async_call_reply/3}).
-dialyzer({nowarn_function,v_msg_async_call_reply/3}).
v_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Path, TrUserData) ->
if F1 == undefined -> ok;
true -> v_type_uint32(F1, [code | Path], TrUserData)
end,
@ -2029,7 +2029,7 @@ v_msg_push_reply(#push_reply{code = F1, result = F2, message = F3}, Path, TrUser
true -> v_type_string(F3, [message | Path], TrUserData)
end,
ok;
v_msg_push_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, push_reply}, X, Path).
v_msg_async_call_reply(X, Path, _TrUserData) -> mk_type_error({expected_msg, async_call_reply}, X, Path).
-compile({nowarn_unused_function,v_msg_deploy/3}).
-dialyzer({nowarn_function,v_msg_deploy/3}).
@ -2262,7 +2262,7 @@ get_msg_defs() ->
#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, 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, push_reply},
{{msg, async_call_reply},
[#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 = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
@ -2308,13 +2308,13 @@ get_msg_defs() ->
#field{name = params, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}].
get_msg_names() -> [auth_request, auth_reply, pub, push_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
get_msg_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
get_group_names() -> [].
get_msg_or_group_names() -> [auth_request, auth_reply, pub, push_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
get_msg_or_group_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, invoke, service_config, data, ping, service_inform, event].
get_enum_names() -> [].
@ -2339,7 +2339,7 @@ find_msg_def(auth_request) ->
#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(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(push_reply) ->
find_msg_def(async_call_reply) ->
[#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 = message, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
@ -2444,7 +2444,7 @@ 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(<<"AuthReply">>) -> auth_reply;
fqbin_to_msg_name(<<"Pub">>) -> pub;
fqbin_to_msg_name(<<"PushReply">>) -> push_reply;
fqbin_to_msg_name(<<"AsyncCallReply">>) -> async_call_reply;
fqbin_to_msg_name(<<"Deploy">>) -> deploy;
fqbin_to_msg_name(<<"FetchTaskLog">>) -> fetch_task_log;
fqbin_to_msg_name(<<"Invoke">>) -> invoke;
@ -2459,7 +2459,7 @@ fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin(auth_request) -> <<"AuthRequest">>;
msg_name_to_fqbin(auth_reply) -> <<"AuthReply">>;
msg_name_to_fqbin(pub) -> <<"Pub">>;
msg_name_to_fqbin(push_reply) -> <<"PushReply">>;
msg_name_to_fqbin(async_call_reply) -> <<"AsyncCallReply">>;
msg_name_to_fqbin(deploy) -> <<"Deploy">>;
msg_name_to_fqbin(fetch_task_log) -> <<"FetchTaskLog">>;
msg_name_to_fqbin(invoke) -> <<"Invoke">>;
@ -2506,7 +2506,7 @@ get_all_source_basenames() -> ["message_pb.proto"].
get_all_proto_names() -> ["message_pb"].
get_msg_containment("message_pb") -> [auth_reply, auth_request, data, deploy, event, fetch_task_log, invoke, ping, pub, push_reply, service_config, service_inform];
get_msg_containment("message_pb") -> [async_call_reply, auth_reply, auth_request, data, deploy, event, fetch_task_log, invoke, ping, pub, service_config, service_inform];
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
@ -2534,9 +2534,9 @@ get_proto_by_msg_name_as_fqbin(<<"Invoke">>) -> "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(<<"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(<<"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(E) -> error({gpb_error, {badmsg, E}}).

View File

@ -24,7 +24,7 @@ message Pub {
/////
message PushReply {
message AsyncCallReply {
// 0: 1:
uint32 code = 1;
string result = 2;