WIP: PB wrestling
This commit is contained in:
parent
37a8c1c124
commit
87b636a349
3 changed files with 60 additions and 9 deletions
|
@ -88,7 +88,7 @@ csv_to_tuples(String) ->
|
|||
[Code, Message, Proto] = string:tokens(Line, ","),
|
||||
{list_to_integer(Code), string:to_lower(Message), Proto ++ "_pb"}
|
||||
end
|
||||
|| Line <- Lines].
|
||||
|| Line <- Lines, length(Line) > 0 andalso hd(Line) /= $#].
|
||||
|
||||
generate_module(Name, Tuples) ->
|
||||
%% TODO: Add generated doc comment at the top
|
||||
|
|
|
@ -50,9 +50,9 @@ enum MpbCSumType {
|
|||
|
||||
// chunk_pos() type
|
||||
message MpbChunkPos {
|
||||
required uint32 offset = 1;
|
||||
required uint32 chunk_size = 2;
|
||||
required bytes file_name = 3;
|
||||
required uint64 offset = 1;
|
||||
required uint64 chunk_size = 2;
|
||||
required string file_name = 3;
|
||||
}
|
||||
|
||||
// chunk_csum() type
|
||||
|
@ -69,10 +69,20 @@ message MpbEpochId {
|
|||
|
||||
// Error response - may be generated for any Req
|
||||
message MpbErrorResp {
|
||||
required bytes errmsg = 1;
|
||||
required string errmsg = 1;
|
||||
required uint32 errcode = 2;
|
||||
}
|
||||
|
||||
// ping() request
|
||||
|
||||
message MpbEchoReq {
|
||||
optional string message = 1;
|
||||
}
|
||||
|
||||
message MpbEchoResp {
|
||||
optional string message = 1;
|
||||
}
|
||||
|
||||
// append_chunk() request
|
||||
message MpbAppendChunkReq {
|
||||
required string prefix = 1;
|
||||
|
@ -94,4 +104,9 @@ message MpbAuthReq {
|
|||
required bytes password = 2;
|
||||
}
|
||||
|
||||
// Dummy authentication request, not used! Included for demo purposes only.
|
||||
message MpbDummyAuthReq {
|
||||
required bytes user = 1;
|
||||
required bytes password = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,43 @@
|
|||
# Comments begin with pound/hash/octothorpe
|
||||
# Blank lines are permitted, but the line must be truly blank (no
|
||||
# hidden whitespace)!
|
||||
|
||||
# https://developers.google.com/protocol-buffers/docs/proto3
|
||||
#
|
||||
# The machi.proto file defines the message types, but it doesn't
|
||||
# define how the wire format will distinguish between different kinds
|
||||
# of messages. For example:
|
||||
#
|
||||
# 38> Dummy = list_to_binary(machi_pb:encode_mpbdummyauthreq({mpbdummyauthreq, <<"dummy-u">>, <<"dummy-p">>})).
|
||||
# <<10,7,100,117,109,109,121,45,117,18,7,100,117,109,109,121,45,112>>
|
||||
#
|
||||
# 39> machi_pb:decode_mpbauthreq(Dummy).
|
||||
#{mpbauthreq,<<"dummy-u">>,<<"dummy-p">>}
|
||||
#
|
||||
# The above demonstrates that we cannot tell the difference between a
|
||||
# MpbAuthReq message and a MpbDummyAuthReq message because their
|
||||
# Protocol Buffers encodings are identical.
|
||||
#
|
||||
# Basho's Riak KV uses the following conventions to create a working
|
||||
# message passing service.
|
||||
#
|
||||
# 1. Use the first 4 bytes to describe the length of the message that
|
||||
# follows. This is analogous to Erlang/OTP's use of {packet,4} style
|
||||
# PDU boundaries. This length includes the bytes from items #2 and #3
|
||||
# below.
|
||||
# 2. Use the next one byte defined below to tag a particular Protocol Buffer
|
||||
# message type.
|
||||
# 3. The encoded Protocol Buffer message bytes follow.
|
||||
#
|
||||
# We will adopt the same convention for Machi's PB interface.
|
||||
|
||||
0,MpbErrorResp,machi_pbundefined
|
||||
1,MpbPingReq,machi_pbundefined
|
||||
2,MpbAuthReq,machi_pbundefined
|
||||
3,MpbAuthResp,machi_pbundefined
|
||||
4,MpbPingResp,machi_pbundefined
|
||||
|
||||
1,MpbEchoReq,machi_pbundefined
|
||||
2,MpbEchoResp,machi_pbundefined
|
||||
|
||||
3,MpbAuthReq,machi_pbundefined
|
||||
4,MpbAuthResp,machi_pbundefined
|
||||
|
||||
5,MpbAppendChunkReq,machi_pbundefined
|
||||
6,MpbAppendChunkResp,machi_pbundefined
|
||||
|
|
Can't render this file because it contains an unexpected character in line 11 and column 82.
|
Loading…
Reference in a new issue