THRIFT-2856 refactor erlang basic transports and unify interfaces

Client: Erlang
Patch: Nobuaki Sukegawa

Add read_exact default implementation so that every transport is usable
under framed transport.
This commit is contained in:
Nobuaki Sukegawa 2015-10-31 12:17:31 +09:00
parent a559f8d903
commit 149ecc1a5f

View File

@ -101,8 +101,12 @@ when is_integer(Len), Len >= 0 ->
read_exact(Transport = #t_transport{module = Module}, Len) read_exact(Transport = #t_transport{module = Module}, Len)
when is_integer(Len), Len >= 0 -> when is_integer(Len), Len >= 0 ->
case erlang:function_exported(Module, read_exact, 2) of
true ->
{NewState, Result} = Module:read_exact(Transport#t_transport.state, Len), {NewState, Result} = Module:read_exact(Transport#t_transport.state, Len),
{Transport#t_transport{state = NewState}, Result}. {Transport#t_transport{state = NewState}, Result};
false -> read(Transport, Len)
end.
write(Transport = #t_transport{module = Module}, Data) -> write(Transport = #t_transport{module = Module}, Data) ->