85 lines
2.0 KiB
Protocol Buffer
85 lines
2.0 KiB
Protocol Buffer
syntax="proto3";
|
|
package bts.api.persistence;
|
|
option csharp_namespace="bts.api.persistence";
|
|
import "lib/api/apioptions.proto";
|
|
|
|
message Record {
|
|
string key = 1 [(bts.api.key)=true];
|
|
bytes value = 2;
|
|
}
|
|
|
|
// store
|
|
message StoreRequest {string ns = 1; repeated Record record = 2;}
|
|
message StoreResponse {
|
|
enum Result {
|
|
OK = 0;
|
|
EMPTY_NS = 1;
|
|
EMPTY_KEY = 2;
|
|
DUPLICATE_KEY = 3;
|
|
}
|
|
Result result = 1;
|
|
}
|
|
|
|
// remove
|
|
message RemoveRequest {string ns = 1; repeated string key = 2;}
|
|
message RemoveAllRequest {string ns = 1;}
|
|
message RemoveResponse {
|
|
enum Result {
|
|
OK = 0;
|
|
EMPTY_NS = 1;
|
|
EMPTY_KEY = 2;
|
|
NO_SUCH_NS = 3;
|
|
NO_SUCH_KEY = 4;
|
|
DUPLICATE_KEY = 5;
|
|
}
|
|
Result result = 1;
|
|
}
|
|
|
|
// retrieve
|
|
message RetrieveRequest {string ns = 1; repeated string key = 2;}
|
|
message RetrieveAllRequest {string ns = 1;}
|
|
message RetrieveResponse {
|
|
enum Result {
|
|
OK = 0;
|
|
EMPTY_NS = 1;
|
|
EMPTY_KEY = 2;
|
|
NO_SUCH_NS = 3;
|
|
NO_SUCH_KEY = 4;
|
|
DUPLICATE_KEY = 5;
|
|
}
|
|
Result result = 1;
|
|
repeated Record record = 2;
|
|
}
|
|
|
|
// subscribe
|
|
message NamespaceSubArgs {string ns = 1;}
|
|
|
|
service PersistenceService {
|
|
option (bts.api.service_description)="Implements a key value store with live updates";
|
|
|
|
rpc retrieve(RetrieveRequest) returns (RetrieveResponse) {
|
|
option (bts.api.method_description)="Retrieve records with specific key in namespace";
|
|
}
|
|
|
|
rpc retrieve_all(RetrieveAllRequest) returns (RetrieveResponse) {
|
|
option (bts.api.method_description)="Retrieve all records in namespace";
|
|
}
|
|
|
|
rpc remove(RemoveRequest) returns (RemoveResponse) {
|
|
option (bts.api.method_description)="Remove records with specific keys in namespace";
|
|
}
|
|
|
|
rpc remove_all(RemoveAllRequest) returns (RemoveResponse) {
|
|
option (bts.api.method_description)="Remove all records in namespace";
|
|
}
|
|
|
|
rpc store(StoreRequest) returns (StoreResponse) {
|
|
option (bts.api.method_description)="Store records in namespace";
|
|
}
|
|
|
|
rpc ns (NamespaceSubArgs) returns (stream Record) {
|
|
option (bts.api.method_description)="Stream of record updates";
|
|
}
|
|
}
|
|
|