/* ------------------------------------------------------------------- ** ** machi.proto: Protocol Buffers definition for Machi ** ** Copyright (c) 2014-2015 Basho Technologies, Inc. All Rights Reserved. ** ** This file is provided to you under the Apache License, ** Version 2.0 (the "License"); you may not use this file ** except in compliance with the License. You may obtain ** a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, ** software distributed under the License is distributed on an ** "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ** KIND, either express or implied. See the License for the ** specific language governing permissions and limitations ** under the License. ** ** ------------------------------------------------------------------- */ /* ** Revision: 0.1 */ // Java package specifiers option java_package = "com.basho.machi.protobuf"; option java_outer_classname = "MachiPB"; ////////////////////////////////////////// // // enums // ////////////////////////////////////////// enum MpbGeneralStatusCode { OK = 0; BAD_ARG = 1; WEDGED = 2; BAD_CHECKSUM = 3; } // Must match with machi.hrl's values! enum MpbCSumType { CSUM_TAG_NONE = 0; CSUM_TAG_CLIENT_GEN = 1; CSUM_TAG_SERVER_GEN = 2; CSUM_TAG_SERVER_REGEN = 3; } ////////////////////////////////////////// // // basic data types // ////////////////////////////////////////// // chunk_pos() type message MpbChunkPos { required uint64 offset = 1; required uint64 chunk_size = 2; required string file_name = 3; } // chunk_csum() type message MpbChunkCSum { required MpbCSumType type = 1; required bytes csum = 2; } // epoch_id() type message MpbEpochId { required uint32 epoch_num = 1; required MpbChunkCSum epoch_csum = 2; } // Error response - may be generated for any Req message MpbErrorResp { required string errmsg = 1; required uint32 errcode = 2; } ////////////////////////////////////////// // // requests & responses // ////////////////////////////////////////// // ping() request & response message MpbEchoReq { optional string message = 1; } message MpbEchoResp { optional string message = 1; } // Authentication request & response message MpbAuthReq { required bytes user = 1; required bytes password = 2; } message MpbAuthResp { required uint32 code = 1; // TODO: not implemented yet } // append_chunk() request & response message MpbAppendChunkReq { required string prefix = 1; optional bytes placement_key = 2; required bytes chunk = 3; optional uint32 chunk_extra = 4; } message MpbAppendChunkResp { required MpbGeneralStatusCode status = 1; optional MpbChunkPos chunk_pos = 2; optional MbpGeneralError = 3; } ////////////////////////////////////////// // // request & response wrapper // ////////////////////////////////////////// message MpbRequest_v1 { // TODO: If we wish to support pipelined requests sometime in the // future, this is the placeholder to do it. required bytes req_id = 1; // The client should only define one request message. If the client // includes multiple requests here, the server may pick/choose an // arbitrary one. // NOTE: The erlang protobuffs compiler doesn't support 'oneof'. // But 'oneof' appears to be a very tiny memory optimization // that not all languages might care about? (Erlang doesn't) optional MpbEchoReq echo = 10; optional MpbAuthReq auth = 11; optional MpbAppendChunkReq append_chunk = 12; } message MpbResponse_v1 { // TODO: If we wish to support pipelined requests sometime in the // future, this is the placeholder to do it. required bytes req_id = 1; // The server will define only one of the optional responses below. // Generic error response, typically used when something quite // bad/unexpected happened within the server. // Clients should always check this response and, if defined, // ignroe any request-specific response at codes 10+. optional MpbErrorResp = 2; // Specific responses. optional MpbEchoResp echo = 10; optional MpbAuthResp auth = 11; optional MpbAppendChunkResp append_chunk = 12; }