Skip to content
This repository was archived by the owner on May 27, 2022. It is now read-only.

Commit e8c0fbc

Browse files
authored
Merge pull request #4 from AntidoteDB/to_ranch
Bug fixes
2 parents 8361d03 + 1bbb73a commit e8c0fbc

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/antidote_pb_codec.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{application, antidote_pb_codec,
22
[
33
{description, "Protocol buffer codec for Antidote"},
4-
{vsn, "0.0.3"},
4+
{vsn, "0.0.5"},
55
{registered, []},
66
{applications, [
77
kernel,

src/antidote_pb_codec.erl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@
8484
| {static_update_objects, {Clock :: binary(), Properties :: list(), Updates :: [update()]}}
8585
| {static_read_objects, {Clock :: binary(), Properties :: list(), Objects :: [bound_object()]}}
8686
| {read_objects, {Objects :: [bound_object()], TxId :: binary()}}
87-
| {get_connection_descriptor, {}}.
87+
| {get_connection_descriptor, Descriptor :: binary()}.
8888

8989
-type response() ::
9090
{error_response, {ErrorCode :: error_code(), Message :: binary()}}
91-
| {start_transaction_response, Resp :: {ok, TxId :: binary()}}
91+
| {start_transaction_response, {ok, TxId :: binary()}}
9292
| {commit_response, {ok, CommitTime :: any()}| {error, Reason :: error_code()}}
9393
| {static_read_objects_response, {ok, Results :: [{bound_object(), read_result()}], CommitTime :: binary()}}
9494
| {read_objects_response, Resp :: [{bound_object(), read_result()}]}
9595
| {operation_response, ok | {error, Reason :: error_code()}}
96-
| {get_connection_descriptor_resp, {ok, Descriptor :: any()} | {error, Reason :: error_code()}}.
96+
| {get_connection_descriptor_resp, {ok, Descriptor :: binary()} | {error, Reason :: error_code()}}.
9797

9898
-type message() :: request() | response().
9999

100100

101-
102-
103101
messageTypeToCode('ApbErrorResp') -> 0;
104102
messageTypeToCode('ApbRegUpdate') -> 107;
105103
messageTypeToCode('ApbGetRegResp') -> 108;
@@ -216,6 +214,16 @@ decode_message(#'ApbStaticReadObjects'{objects = Objects, transaction = Tx}) ->
216214
decode_message(#'ApbReadObjects'{boundobjects = Objects, transaction_descriptor = TxId}) ->
217215
{read_objects, {[decode_bound_object(O) || O <- Objects], binary_to_term(TxId)}};
218216

217+
decode_message(#'ApbCreateDC'{nodes = Nodes}) ->
218+
{create_dc, [list_to_atom(N) || N <- Nodes]};
219+
decode_message(#'ApbGetConnectionDescriptor'{}) ->
220+
{get_connection_descriptor};
221+
decode_message(#'ApbGetConnectionDescriptorResp'{descriptor = Descriptor}) ->
222+
{get_connection_descriptor, Descriptor};
223+
decode_message(#'ApbConnectToDCs'{descriptors = Descriptors}) ->
224+
{connect_to_dcs, [binary_to_term(D) || D <- Descriptors]};
225+
226+
219227
decode_message(#'ApbErrorResp'{errcode = ErrorCode, errmsg = Message}) ->
220228
{error_response, {decode_error_code(ErrorCode), Message}};
221229
decode_message(#'ApbStartTransactionResp'{success = Success, transaction_descriptor = TxId, errorcode = ErrorCode}) ->
@@ -372,7 +380,8 @@ encode_txn_properties(_Props) ->
372380
#'ApbTxnProperties'{}.
373381

374382
decode_txn_properties(_Properties) ->
375-
{}.
383+
%%TODO: Add more property parameters
384+
[].
376385

377386

378387
%%%%%%%%%%%%%%%%%%%%%
@@ -813,7 +822,7 @@ decode_connect_to_DCs(#'ApbConnectToDCs'{descriptors = Descriptors}) ->
813822
%% Tests encode and decode
814823
start_transaction_test() ->
815824
Clock = term_to_binary(ignore),
816-
Properties = {},
825+
Properties = [],
817826
EncRecord = antidote_pb_codec:encode(start_transaction,
818827
{Clock, Properties}),
819828
[MsgCode, MsgData] = encode_msg(EncRecord),

0 commit comments

Comments
 (0)