Module riak_pb_codec

Utility functions for Protocol Buffers encoding and decoding.

Description

Utility functions for Protocol Buffers encoding and decoding. These are used inside the client and server code and do not normally need to be used in application code.

Data Types

commit_hook_field()

commit_hook_field() = binary()

commit_hook_property()

commit_hook_property() = [{struct, [{commit_hook_field(), binary()}]}]

modfun_property()

modfun_property() = {module(), function()} | {modfun, module(), function()}

Function Index

decode/2Decode a protocol buffer message given its type - if no bytes return the atom for the message code.
decode_bool/1Convert a protocol buffers boolean to an Erlang boolean.
decode_bucket_props/1Convert an RpbBucketProps message to a property list.
decode_commit_hooks/1Converts a list of RpbCommitHook messages into commit hooks.
decode_modfun/2Converts an RpbModFun message into the appropriate format for the given property.
decode_pair/1Convert RpbPair PB message to erlang {K,V} tuple.
decoder_for/1Selects the appropriate decoder for a message code.
encode/1Create an iolist of msg code and encoded message.
encode_bool/1Convert a true/false, 1/0 etc to a true/false for protocol buffers bool.
encode_bucket_props/1Convert a property list to an RpbBucketProps message.
encode_commit_hooks/1Converts a list of commit hooks into a list of RpbCommitHook messages.
encode_modfun/1Converts a module-function specification into a RpbModFun message.
encode_pair/1Convert {K,V} tuple to protocol buffers.
encoder_for/1Selects the appropriate PB encoder for a given message name.
msg_code/1Converts a symbolic message name into a message code.
msg_type/1Converts a message code into the symbolic message name.
to_binary/1Make sure an atom/string/binary is definitely a binary.
to_list/1Converts an arbitrary type to a list for sending in a PB.

Function Details

decode/2

decode(MsgCode::integer(), MsgData::binary()) -> atom() | tuple()

Decode a protocol buffer message given its type - if no bytes return the atom for the message code. Replaces riakc_pb:decode/2.

decode_bool/1

decode_bool(X1::boolean() | integer()) -> boolean()

Convert a protocol buffers boolean to an Erlang boolean. Replaces riakc_pb:erlify_bool/1.

decode_bucket_props/1

decode_bucket_props(PBProps::#rpbbucketprops{n_val = non_neg_integer() | undefined, allow_mult = boolean() | 0 | 1 | undefined, last_write_wins = boolean() | 0 | 1 | undefined, precommit = [#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}], has_precommit = boolean() | 0 | 1 | undefined, postcommit = [#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}], has_postcommit = boolean() | 0 | 1 | undefined, chash_keyfun = #rpbmodfun{module = binary(), function = binary()} | undefined, linkfun = #rpbmodfun{module = binary(), function = binary()} | undefined, old_vclock = non_neg_integer() | undefined, young_vclock = non_neg_integer() | undefined, big_vclock = non_neg_integer() | undefined, small_vclock = non_neg_integer() | undefined, pr = non_neg_integer() | undefined, r = non_neg_integer() | undefined, w = non_neg_integer() | undefined, pw = non_neg_integer() | undefined, dw = non_neg_integer() | undefined, rw = non_neg_integer() | undefined, basic_quorum = boolean() | 0 | 1 | undefined, notfound_ok = boolean() | 0 | 1 | undefined, backend = binary() | undefined, search = boolean() | 0 | 1 | undefined, repl = 'FALSE' | 'REALTIME' | 'FULLSYNC' | 'TRUE' | integer() | undefined, search_index = binary() | undefined, datatype = binary() | undefined, consistent = boolean() | 0 | 1 | undefined, write_once = boolean() | 0 | 1 | undefined, hll_precision = non_neg_integer() | undefined, ttl = non_neg_integer() | undefined} | undefined) -> [proplists:property()]

Convert an RpbBucketProps message to a property list

decode_commit_hooks/1

decode_commit_hooks(Hooks::[#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}]) -> [commit_hook_property()]

Converts a list of RpbCommitHook messages into commit hooks.

decode_modfun/2

decode_modfun(Rpbmodfun::#rpbmodfun{module = binary(), function = binary()}, Prop::atom()) -> modfun_property()

Converts an RpbModFun message into the appropriate format for the given property.

decode_pair/1

decode_pair(Rpbpair::#rpbpair{key = binary(), value = binary() | undefined}) -> {binary(), binary()}

Convert RpbPair PB message to erlang {K,V} tuple

decoder_for/1

decoder_for(N::pos_integer()) -> module()

Selects the appropriate decoder for a message code.

encode/1

encode(Msg::atom() | tuple()) -> iolist()

Create an iolist of msg code and encoded message. Replaces riakc_pb:encode/1.

encode_bool/1

encode_bool(N::boolean() | integer()) -> boolean()

Convert a true/false, 1/0 etc to a true/false for protocol buffers bool. Replaces riakc_pb:pbify_bool/1.

encode_bucket_props/1

encode_bucket_props(Props::[proplists:property()]) -> PBProps::#rpbbucketprops{n_val = non_neg_integer() | undefined, allow_mult = boolean() | 0 | 1 | undefined, last_write_wins = boolean() | 0 | 1 | undefined, precommit = [#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}], has_precommit = boolean() | 0 | 1 | undefined, postcommit = [#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}], has_postcommit = boolean() | 0 | 1 | undefined, chash_keyfun = #rpbmodfun{module = binary(), function = binary()} | undefined, linkfun = #rpbmodfun{module = binary(), function = binary()} | undefined, old_vclock = non_neg_integer() | undefined, young_vclock = non_neg_integer() | undefined, big_vclock = non_neg_integer() | undefined, small_vclock = non_neg_integer() | undefined, pr = non_neg_integer() | undefined, r = non_neg_integer() | undefined, w = non_neg_integer() | undefined, pw = non_neg_integer() | undefined, dw = non_neg_integer() | undefined, rw = non_neg_integer() | undefined, basic_quorum = boolean() | 0 | 1 | undefined, notfound_ok = boolean() | 0 | 1 | undefined, backend = binary() | undefined, search = boolean() | 0 | 1 | undefined, repl = 'FALSE' | 'REALTIME' | 'FULLSYNC' | 'TRUE' | integer() | undefined, search_index = binary() | undefined, datatype = binary() | undefined, consistent = boolean() | 0 | 1 | undefined, write_once = boolean() | 0 | 1 | undefined, hll_precision = non_neg_integer() | undefined, ttl = non_neg_integer() | undefined}

Convert a property list to an RpbBucketProps message

encode_commit_hooks/1

encode_commit_hooks(Hooks::[commit_hook_property()]) -> [#rpbcommithook{modfun = #rpbmodfun{module = binary(), function = binary()} | undefined, name = binary() | undefined}]

Converts a list of commit hooks into a list of RpbCommitHook messages.

encode_modfun/1

encode_modfun(X1::modfun_property()) -> #rpbmodfun{module = binary(), function = binary()}

Converts a module-function specification into a RpbModFun message.

encode_pair/1

encode_pair(X1::{Key::binary(), Value::any()}) -> #rpbpair{key = binary(), value = binary() | undefined}

Convert {K,V} tuple to protocol buffers

encoder_for/1

encoder_for(M::atom()) -> module()

Selects the appropriate PB encoder for a given message name.

msg_code/1

msg_code(Atom::atom()) -> integer()

Converts a symbolic message name into a message code. Replaces riakc_pb:msg_code/1.

msg_type/1

msg_type(Int::integer()) -> atom()

Converts a message code into the symbolic message name. Replaces riakc_pb:msg_type/1.

to_binary/1

to_binary(A::atom() | string() | binary()) -> binary()

Make sure an atom/string/binary is definitely a binary. Replaces riakc_pb:to_binary/1.

to_list/1

to_list(V::list() | atom() | binary() | integer()) -> list()

Converts an arbitrary type to a list for sending in a PB. Replaces riakc_pb:any_to_list/1.


Generated by EDoc