gorealis v2 refactor (#5)

* Changing default timeout for start maintenance.

* Upgrading dependencies to gorealis v2 and thrift  0.12.0

* Refactored to update to gorealis v2.
This commit is contained in:
Renan DelValle 2018-12-27 11:31:51 -08:00 committed by GitHub
parent ad4dd9606e
commit 6ab5c9334d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1335 changed files with 137431 additions and 61530 deletions

View file

@ -62,7 +62,8 @@ when is_integer(Len), Len >= 0 ->
Give = min(iolist_size(NewBinary), Len),
{Result, Remaining} = split_binary(NewBinary, Give),
{State#t_framed{wrapped = NewState, read_buffer = Remaining}, {ok, Result}};
Error -> Error
{NewState, Error} ->
{State#t_framed{wrapped = NewState}, Error}
end;
%% read of zero bytes
<<>> -> {State, {ok, <<>>}};

View file

@ -219,12 +219,11 @@ read_struct_loop(IProto0, SDict, RTuple) ->
end.
skip_field(FType, IProto0, SDict, RTuple) ->
FTypeAtom = thrift_protocol:typeid_to_atom(FType),
{IProto1, ok} = thrift_protocol:skip(IProto0, FTypeAtom),
{IProto1, ok} = skip(IProto0, typeid_to_atom(FType)),
{IProto2, ok} = read(IProto1, field_end),
read_struct_loop(IProto2, SDict, RTuple).
-spec skip(#protocol{}, any()) -> {#protocol{}, ok}.
-spec skip(#protocol{}, atom()) -> {#protocol{}, ok}.
skip(Proto0, struct) ->
{Proto1, ok} = read(Proto0, struct_begin),
@ -261,7 +260,7 @@ skip_struct_loop(Proto0) ->
?tType_STOP ->
{Proto1, ok};
_Else ->
{Proto2, ok} = skip(Proto1, Type),
{Proto2, ok} = skip(Proto1, typeid_to_atom(Type)),
{Proto3, ok} = read(Proto2, field_end),
skip_struct_loop(Proto3)
end.
@ -271,8 +270,8 @@ skip_map_loop(Proto0, Map = #protocol_map_begin{ktype = Ktype,
size = Size}) ->
case Size of
N when N > 0 ->
{Proto1, ok} = skip(Proto0, Ktype),
{Proto2, ok} = skip(Proto1, Vtype),
{Proto1, ok} = skip(Proto0, typeid_to_atom(Ktype)),
{Proto2, ok} = skip(Proto1, typeid_to_atom(Vtype)),
skip_map_loop(Proto2,
Map#protocol_map_begin{size = Size - 1});
0 -> {Proto0, ok}
@ -282,7 +281,7 @@ skip_set_loop(Proto0, Map = #protocol_set_begin{etype = Etype,
size = Size}) ->
case Size of
N when N > 0 ->
{Proto1, ok} = skip(Proto0, Etype),
{Proto1, ok} = skip(Proto0, typeid_to_atom(Etype)),
skip_set_loop(Proto1,
Map#protocol_set_begin{size = Size - 1});
0 -> {Proto0, ok}
@ -292,7 +291,7 @@ skip_list_loop(Proto0, Map = #protocol_list_begin{etype = Etype,
size = Size}) ->
case Size of
N when N > 0 ->
{Proto1, ok} = skip(Proto0, Etype),
{Proto1, ok} = skip(Proto0, typeid_to_atom(Etype)),
skip_list_loop(Proto1,
Map#protocol_list_begin{size = Size - 1});
0 -> {Proto0, ok}

View file

@ -36,7 +36,7 @@
terminate/2,
code_change/3 ]).
-record( state, { client = nil,
-record( state, { client = nil,
host,
port,
thrift_svc,
@ -226,9 +226,9 @@ timer_fun() ->
end.
-else.
timer_fun() ->
T1 = erlang:now(),
T1 = erlang:timestamp(),
fun() ->
T2 = erlang:now(),
T2 = erlang:timestamp(),
timer:now_diff(T2, T1)
end.
-endif.

View file

@ -103,11 +103,9 @@ read_exact(Transport = #t_transport{module = Module}, Len)
when is_integer(Len), Len >= 0 ->
case lists:keyfind(read_exact, 1, Module:module_info(exports)) of
{read_exact, 2} ->
io:fwrite("HAS EXACT"),
{NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
{Transport#t_transport{state = NewState}, Result};
_ ->
io:fwrite("~p NO EXACT", [Module]),
read(Transport, Len)
end.