fix transport
This commit is contained in:
parent
f56d049bfe
commit
0eb6eb1e7a
@ -35,15 +35,6 @@
|
||||
}).
|
||||
-endif.
|
||||
|
||||
-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
|
||||
}).
|
||||
-endif.
|
||||
|
||||
-ifndef('DEPLOY_PB_H').
|
||||
-define('DEPLOY_PB_H', true).
|
||||
-record(deploy,
|
||||
|
||||
@ -232,12 +232,12 @@ handle_event(info, {server_rpc, PacketId, <<?RPC_DEPLOY:8, DeployBin/binary>>},
|
||||
%% 短暂的等待,efka_inetd收到消息后就立即返回了
|
||||
case docker_manager:deploy(TaskId, Config) of
|
||||
ok ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
{error, Reason} when is_binary(Reason) ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
end;
|
||||
_Error ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_error(<<"invalid config json">>))
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_error(<<"invalid config json">>))
|
||||
end,
|
||||
{keep_state, State};
|
||||
|
||||
@ -246,9 +246,9 @@ handle_event(info, {server_rpc, PacketId, <<?RPC_START_CONTAINER:8, ServiceId/bi
|
||||
%% 短暂的等待,efka_inetd收到消息后就立即返回了
|
||||
case docker_manager:start_container(ServiceId) of
|
||||
ok ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
{error, Reason} when is_binary(Reason) ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
end,
|
||||
{keep_state, State};
|
||||
|
||||
@ -257,9 +257,9 @@ handle_event(info, {server_rpc, PacketId, <<?RPC_STOP_CONTAINER:8, ServiceId/bin
|
||||
%% 短暂的等待,efka_inetd收到消息后就立即返回了
|
||||
case docker_manager:stop_container(ServiceId) of
|
||||
ok ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
{error, Reason} when is_binary(Reason) ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
end,
|
||||
{keep_state, State};
|
||||
|
||||
@ -269,9 +269,9 @@ handle_event(info, {server_rpc, PacketId, <<?RPC_CONFIG_CONTAINER:8, ConfigBin/b
|
||||
|
||||
case docker_manager:config_container(ContainerName, Config) of
|
||||
ok ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_success(<<"ok">>));
|
||||
{error, Reason} ->
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
efka_transport:rpc_reply(TransportPid, PacketId, reply_error(Reason))
|
||||
end,
|
||||
{keep_state, State};
|
||||
|
||||
@ -313,23 +313,6 @@ handle_event(info, {server_pub, Topic, Content}, ?STATE_ACTIVATED, State) ->
|
||||
efka_subscription:publish(Topic, Content),
|
||||
{keep_state, State};
|
||||
|
||||
%% 收到来自efka_service的回复
|
||||
handle_event(info, {service_reply, Ref, EmsReply}, ?STATE_ACTIVATED, State = #state{push_inflight = PushInflight, transport_pid = TransportPid}) ->
|
||||
case maps:take(Ref, PushInflight) of
|
||||
error ->
|
||||
{keep_state, State};
|
||||
{PacketId, NPushInflight} ->
|
||||
Reply = case EmsReply of
|
||||
{ok, Result} ->
|
||||
#async_call_reply{code = 1, result = Result};
|
||||
{error, Reason} ->
|
||||
#async_call_reply{code = 0, message = Reason}
|
||||
end,
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)),
|
||||
|
||||
{keep_state, State#state{push_inflight = NPushInflight}}
|
||||
end;
|
||||
|
||||
%% 收到来自服务器端的回复
|
||||
handle_event(info, {server_reply, Ref, ReplyBin}, ?STATE_ACTIVATED, State = #state{request_inflight = RequestInflight}) ->
|
||||
case maps:take(Ref, RequestInflight) of
|
||||
@ -340,18 +323,6 @@ handle_event(info, {server_reply, Ref, ReplyBin}, ?STATE_ACTIVATED, State = #sta
|
||||
{keep_state, State#state{push_inflight = NRequestInflight}}
|
||||
end;
|
||||
|
||||
%% todo 请求超时逻辑处理
|
||||
handle_event(info, {timeout, _, {request_timeout, Ref}}, ?STATE_ACTIVATED, State = #state{push_inflight = PushInflight, transport_pid = TransportPid}) ->
|
||||
case maps:take(Ref, PushInflight) of
|
||||
error ->
|
||||
{keep_state, State};
|
||||
{PacketId, NPushInflight} ->
|
||||
Reply = #async_call_reply{code = 0, message = <<"reqeust timeout">>, result = <<>>},
|
||||
efka_transport:async_call_reply(TransportPid, PacketId, message_pb:encode_msg(Reply)),
|
||||
|
||||
{keep_state, State#state{push_inflight = NPushInflight}}
|
||||
end;
|
||||
|
||||
%% transport进程退出
|
||||
handle_event(info, {'DOWN', MRef, process, TransportPid, Reason}, _, State = #state{transport_ref = MRef}) ->
|
||||
lager:debug("[efka_remote_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
|
||||
@ -399,10 +370,8 @@ auth_request() ->
|
||||
|
||||
-spec reply_success(Result :: binary()) -> binary().
|
||||
reply_success(Result) when is_binary(Result) ->
|
||||
Reply = #async_call_reply{code = 1, result = Result},
|
||||
message_pb:encode_msg(Reply).
|
||||
<<1:8, Result/binary>>.
|
||||
|
||||
-spec reply_error(Message :: binary()) -> binary().
|
||||
reply_error(Message) when is_binary(Message) ->
|
||||
Reply = #async_call_reply{code = 1, message = Message},
|
||||
message_pb:encode_msg(Reply).
|
||||
<<0:8, Message/binary>>.
|
||||
@ -15,8 +15,7 @@
|
||||
|
||||
%% API
|
||||
-export([start_monitor/3]).
|
||||
-export([connect/1, auth_request/2, send/3, async_call_reply/3, stop/1]).
|
||||
-export([request/3]).
|
||||
-export([connect/1, auth_request/2, send/3, rpc_reply/3, stop/1]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
|
||||
@ -38,12 +37,6 @@
|
||||
auth_request(Pid, AuthBin) when is_pid(Pid), is_binary(AuthBin) ->
|
||||
gen_server:cast(Pid, {auth_request, AuthBin}).
|
||||
|
||||
-spec request(Pid :: pid(), Method :: integer(), ReqBin :: binary()) -> Ref :: reference().
|
||||
request(Pid, Method, ReqBin) when is_pid(Pid), is_binary(ReqBin) ->
|
||||
Ref = make_ref(),
|
||||
gen_server:cast(Pid, {request, Ref, Method, ReqBin}),
|
||||
Ref.
|
||||
|
||||
-spec connect(Pid :: pid()) -> no_return().
|
||||
connect(Pid) when is_pid(Pid) ->
|
||||
gen_server:cast(Pid, connect).
|
||||
@ -52,11 +45,11 @@ 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 async_call_reply(Pid :: pid() | undefined, PacketId :: integer(), Response :: binary()) -> no_return().
|
||||
async_call_reply(undefined, PacketId, Response) when is_integer(PacketId), is_binary(Response) ->
|
||||
-spec rpc_reply(Pid :: pid() | undefined, PacketId :: integer(), Response :: binary()) -> no_return().
|
||||
rpc_reply(undefined, PacketId, Response) when is_integer(PacketId), is_binary(Response) ->
|
||||
ok;
|
||||
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}).
|
||||
rpc_reply(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId), is_binary(Response) ->
|
||||
gen_server:cast(Pid, {rpc_reply, PacketId, Response}).
|
||||
|
||||
%% 关闭的时候不一定能成功,可能关闭的时候;transport进程已经退出了
|
||||
-spec stop(Pid :: pid() | undefined) -> ok.
|
||||
@ -121,7 +114,8 @@ handle_cast(connect, State = #state{host = Host, port = Port, parent_pid = Paren
|
||||
|
||||
%% auth校验
|
||||
handle_cast({auth_request, AuthRequestBin}, State = #state{parent_pid = ParentPid, socket = Socket}) ->
|
||||
ok = ssl:send(Socket, <<?PACKET_REQUEST, 1:32, ?METHOD_AUTH, AuthRequestBin/binary>>),
|
||||
PacketId = 1,
|
||||
ok = ssl:send(Socket, <<?PACKET_REQUEST, PacketId:32, ?METHOD_AUTH, AuthRequestBin/binary>>),
|
||||
%% 需要等待auth返回的结果
|
||||
receive
|
||||
{ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ReplyBin/binary>>} ->
|
||||
@ -137,11 +131,11 @@ handle_cast({auth_request, AuthRequestBin}, State = #state{parent_pid = ParentPi
|
||||
end;
|
||||
|
||||
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:8, Packet/binary>>),
|
||||
{noreply, State};
|
||||
|
||||
%% 服务push的消息的回复
|
||||
handle_cast({async_call_reply, PacketId, Response}, State = #state{socket = Socket}) ->
|
||||
handle_cast({rpc_reply, PacketId, Response}, State = #state{socket = Socket}) ->
|
||||
ok = ssl:send(Socket, <<?PACKET_RPC_REPLY, PacketId:32, Response/binary>>),
|
||||
{noreply, State}.
|
||||
|
||||
@ -162,7 +156,7 @@ handle_info({ssl, Socket, <<?PACKET_PUB, PubBin/binary>>}, State = #state{socket
|
||||
{noreply, State};
|
||||
|
||||
handle_info({ssl, Socket, <<?PACKET_RPC, PacketId:32, AsyncCallBin/binary>>}, State = #state{socket = Socket, parent_pid = ParentPid}) ->
|
||||
ParentPid ! {server_async_call, PacketId, AsyncCallBin},
|
||||
ParentPid ! {server_rpc, PacketId, AsyncCallBin},
|
||||
{noreply, State};
|
||||
|
||||
handle_info({ssl_error, Socket, Reason}, State = #state{socket = Socket}) ->
|
||||
|
||||
@ -61,8 +61,6 @@
|
||||
|
||||
-type pub() :: #pub{}.
|
||||
|
||||
-type async_call_reply() :: #async_call_reply{}.
|
||||
|
||||
-type deploy() :: #deploy{}.
|
||||
|
||||
-type fetch_task_log() :: #fetch_task_log{}.
|
||||
@ -75,9 +73,9 @@
|
||||
|
||||
-type ping() :: #ping{}.
|
||||
|
||||
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'async_call_reply'/0, 'deploy'/0, 'fetch_task_log'/0, 'container_config'/0, 'data'/0, 'event'/0, 'ping'/0]).
|
||||
-type '$msg_name'() :: auth_request | auth_reply | pub | async_call_reply | deploy | fetch_task_log | container_config | data | event | ping.
|
||||
-type '$msg'() :: auth_request() | auth_reply() | pub() | async_call_reply() | deploy() | fetch_task_log() | container_config() | data() | event() | ping().
|
||||
-export_type(['auth_request'/0, 'auth_reply'/0, 'pub'/0, 'deploy'/0, 'fetch_task_log'/0, 'container_config'/0, 'data'/0, 'event'/0, 'ping'/0]).
|
||||
-type '$msg_name'() :: auth_request | auth_reply | pub | deploy | fetch_task_log | container_config | data | event | ping.
|
||||
-type '$msg'() :: auth_request() | auth_reply() | pub() | deploy() | fetch_task_log() | container_config() | data() | event() | ping().
|
||||
-export_type(['$msg_name'/0, '$msg'/0]).
|
||||
|
||||
-if(?OTP_RELEASE >= 24).
|
||||
@ -107,7 +105,6 @@ 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);
|
||||
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);
|
||||
container_config -> encode_msg_container_config(id(Msg, TrUserData), TrUserData);
|
||||
@ -220,40 +217,6 @@ encode_msg_pub(#pub{topic = F1, content = F2}, Bin, TrUserData) ->
|
||||
end
|
||||
end.
|
||||
|
||||
encode_msg_async_call_reply(Msg, TrUserData) -> encode_msg_async_call_reply(Msg, <<>>, TrUserData).
|
||||
|
||||
|
||||
encode_msg_async_call_reply(#async_call_reply{code = F1, result = F2, message = F3}, Bin, TrUserData) ->
|
||||
B1 = 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,
|
||||
B2 = if F2 == undefined -> B1;
|
||||
true ->
|
||||
begin
|
||||
TrF2 = id(F2, TrUserData),
|
||||
case is_empty_string(TrF2) of
|
||||
true -> B1;
|
||||
false -> e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
|
||||
end
|
||||
end
|
||||
end,
|
||||
if F3 == undefined -> B2;
|
||||
true ->
|
||||
begin
|
||||
TrF3 = id(F3, TrUserData),
|
||||
case is_empty_string(TrF3) of
|
||||
true -> B2;
|
||||
false -> e_type_string(TrF3, <<B2/binary, 26>>, TrUserData)
|
||||
end
|
||||
end
|
||||
end.
|
||||
|
||||
encode_msg_deploy(Msg, TrUserData) -> encode_msg_deploy(Msg, <<>>, TrUserData).
|
||||
|
||||
|
||||
@ -686,7 +649,6 @@ 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(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(container_config, Bin, TrUserData) -> id(decode_msg_container_config(Bin, TrUserData), TrUserData);
|
||||
@ -870,64 +832,6 @@ 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_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_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_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_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_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_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_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_async_call_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_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_async_call_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_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_async_call_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_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_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_async_call_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) ->
|
||||
{_, Rest} = read_group(Bin, FNum),
|
||||
dfp_read_field_def_async_call_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_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), TrUserData).
|
||||
|
||||
dfp_read_field_def_deploy(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_deploy_task_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
|
||||
@ -1486,7 +1390,6 @@ 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);
|
||||
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);
|
||||
container_config -> merge_msg_container_config(Prev, New, TrUserData);
|
||||
@ -1540,21 +1443,6 @@ merge_msg_pub(#pub{topic = PFtopic, content = PFcontent}, #pub{topic = NFtopic,
|
||||
true -> NFcontent
|
||||
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, config = PFconfig}, #deploy{task_id = NFtask_id, config = NFconfig}, _) ->
|
||||
#deploy{task_id =
|
||||
@ -1694,7 +1582,6 @@ 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);
|
||||
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);
|
||||
container_config -> v_msg_container_config(Msg, [MsgName], TrUserData);
|
||||
@ -1750,21 +1637,6 @@ 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_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,
|
||||
if F2 == undefined -> ok;
|
||||
true -> v_type_string(F2, [result | Path], TrUserData)
|
||||
end,
|
||||
if F3 == undefined -> ok;
|
||||
true -> v_type_string(F3, [message | Path], TrUserData)
|
||||
end,
|
||||
ok;
|
||||
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}).
|
||||
v_msg_deploy(#deploy{task_id = F1, config = F2}, Path, TrUserData) ->
|
||||
@ -1966,10 +1838,6 @@ 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 = bytes, occurrence = optional, opts = []}]},
|
||||
{{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 = []}]},
|
||||
{{msg, deploy}, [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = config, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}]},
|
||||
{{msg, fetch_task_log}, [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}]},
|
||||
{{msg, container_config}, [#field{name = container_name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = config, fnum = 2, rnum = 3, type = bytes, occurrence = optional, opts = []}]},
|
||||
@ -1998,13 +1866,13 @@ get_msg_defs() ->
|
||||
#field{name = interfaces, fnum = 13, rnum = 14, type = string, occurrence = optional, opts = []}]}].
|
||||
|
||||
|
||||
get_msg_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, container_config, data, event, ping].
|
||||
get_msg_names() -> [auth_request, auth_reply, pub, deploy, fetch_task_log, container_config, data, event, ping].
|
||||
|
||||
|
||||
get_group_names() -> [].
|
||||
|
||||
|
||||
get_msg_or_group_names() -> [auth_request, auth_reply, pub, async_call_reply, deploy, fetch_task_log, container_config, data, event, ping].
|
||||
get_msg_or_group_names() -> [auth_request, auth_reply, pub, deploy, fetch_task_log, container_config, data, event, ping].
|
||||
|
||||
|
||||
get_enum_names() -> [].
|
||||
@ -2029,10 +1897,6 @@ 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 = bytes, occurrence = optional, opts = []}];
|
||||
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 = []}];
|
||||
find_msg_def(deploy) -> [#field{name = task_id, fnum = 1, rnum = 2, type = uint32, occurrence = optional, opts = []}, #field{name = config, fnum = 2, rnum = 3, 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(container_config) -> [#field{name = container_name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = config, fnum = 2, rnum = 3, type = bytes, occurrence = optional, opts = []}];
|
||||
@ -2120,7 +1984,6 @@ 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(<<"AsyncCallReply">>) -> async_call_reply;
|
||||
fqbin_to_msg_name(<<"Deploy">>) -> deploy;
|
||||
fqbin_to_msg_name(<<"FetchTaskLog">>) -> fetch_task_log;
|
||||
fqbin_to_msg_name(<<"ContainerConfig">>) -> container_config;
|
||||
@ -2133,7 +1996,6 @@ 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(async_call_reply) -> <<"AsyncCallReply">>;
|
||||
msg_name_to_fqbin(deploy) -> <<"Deploy">>;
|
||||
msg_name_to_fqbin(fetch_task_log) -> <<"FetchTaskLog">>;
|
||||
msg_name_to_fqbin(container_config) -> <<"ContainerConfig">>;
|
||||
@ -2178,7 +2040,7 @@ get_all_source_basenames() -> ["message_pb.proto"].
|
||||
get_all_proto_names() -> ["message_pb"].
|
||||
|
||||
|
||||
get_msg_containment("message_pb") -> [async_call_reply, auth_reply, auth_request, container_config, data, deploy, event, fetch_task_log, ping, pub];
|
||||
get_msg_containment("message_pb") -> [auth_reply, auth_request, container_config, data, deploy, event, fetch_task_log, ping, pub];
|
||||
get_msg_containment(P) -> error({gpb_error, {badproto, P}}).
|
||||
|
||||
|
||||
@ -2207,7 +2069,6 @@ get_proto_by_msg_name_as_fqbin(<<"FetchTaskLog">>) -> "message_pb";
|
||||
get_proto_by_msg_name_as_fqbin(<<"ContainerConfig">>) -> "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(E) -> error({gpb_error, {badmsg, E}}).
|
||||
|
||||
|
||||
|
||||
@ -24,13 +24,6 @@ message Pub {
|
||||
|
||||
///// 服务器主动推送的消息
|
||||
|
||||
message AsyncCallReply {
|
||||
// 0: 表示失败,1: 成功
|
||||
uint32 code = 1;
|
||||
string result = 2;
|
||||
string message = 3;
|
||||
}
|
||||
|
||||
// 部署逻辑
|
||||
message Deploy {
|
||||
uint32 task_id = 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user