60 lines
1.1 KiB
Protocol Buffer
60 lines
1.1 KiB
Protocol Buffer
syntax = "proto3";
|
|
package consensusProto;
|
|
|
|
option go_package = "consensus/consensusproto";
|
|
|
|
enum ErrCodes {
|
|
Unexpected = 0;
|
|
LogExists = 1;
|
|
LogNotFound = 2;
|
|
RecordConflict = 3;
|
|
ErrorOffset = 500;
|
|
}
|
|
|
|
|
|
message Log {
|
|
bytes id = 1;
|
|
repeated Record records = 2;
|
|
}
|
|
|
|
message Record {
|
|
bytes id = 1;
|
|
bytes prevId = 2;
|
|
bytes payload = 3;
|
|
uint64 createdUnix = 4;
|
|
}
|
|
|
|
service Consensus {
|
|
// AddLog adds new log to consensus
|
|
rpc LogAdd(LogAddRequest) returns (Ok);
|
|
// AddRecord adds new record to log
|
|
rpc RecordAdd(RecordAddRequest) returns (Ok);
|
|
// WatchLog fetches log and subscribes for a changes
|
|
rpc LogWatch(stream LogWatchRequest) returns (stream LogWatchEvent);
|
|
}
|
|
|
|
message Ok {}
|
|
|
|
message LogAddRequest {
|
|
Log log = 1;
|
|
}
|
|
|
|
message RecordAddRequest {
|
|
bytes logId = 1;
|
|
Record record = 2;
|
|
}
|
|
|
|
message LogWatchRequest {
|
|
repeated bytes watchIds = 1;
|
|
repeated bytes unwatchIds = 2;
|
|
}
|
|
|
|
message LogWatchEvent {
|
|
bytes logId = 1;
|
|
repeated Record records = 2;
|
|
Err error = 3;
|
|
}
|
|
|
|
message Err {
|
|
ErrCodes error = 1;
|
|
} |