Skip to content

Instantly share code, notes, and snippets.

@DocSavage
Last active August 29, 2015 14:21
Show Gist options
  • Save DocSavage/0536c9dfaf3af9fbb37f to your computer and use it in GitHub Desktop.
Save DocSavage/0536c9dfaf3af9fbb37f to your computer and use it in GitHub Desktop.
Immutable Ordered Key-Value Store API
// The API can be implemented as HTTP API, gRPC API, and/or Go code level API.
// The specification below uses Google Protobuf 3 IDL and gRPC framework:
// http://www.grpc.io/faq/
// For overview of implementing service with this specification:
// https://github.com/grpc/grpc-common
syntax = "proto3";
package immstore;
message KeyValue {
bytes key = 1;
bytes value = 2;
}
message KeyRange {
bytes key_beg = 1;
bytes key_end = 2;
}
message VersionedDataID {
uint32 app_id = 1;
uint32 version_id = 2;
uint32 data_id = 3;
}
message GetRequest {
VersionedDataID id = 1;
bytes key = 2;
}
message PutRequest {
VersionedDataID id = 1;
KeyValue kv = 2;
}
message RangeRequest {
VersionedDataID id = 1;
KeyRange range = 2;
}
message StatusReply {
enum Status {
ERROR = 0;
OK = 1;
BADKEY = 2;
}
Status status = 1;
}
message KeysReply {
enum Status {
ERROR = 0;
OK = 1;
BADKEY = 2;
}
Status status = 1;
repeated bytes keys = 2;
}
message ValueReply {
enum Status {
ERROR = 0;
OK = 1;
BADKEY = 2;
}
Status status = 1;
bytes value = 2;
}
message KeyValueReply {
enum Status {
ERROR = 0;
OK = 1;
BADKEY = 2;
}
Status status = 1;
KeyValue kv = 2;
}
service ImmutableOrderedKV {
// Get returns the value bytes corresponding to a key
rpc Get(GetRequest) returns (ValueReply) {}
// Put stores the given key-value pair. It is an error if the
// key already has a stored value.
rpc Put(PutRequest) returns (StatusReply) {}
// GetRange returns all key-value pairs stored within a range of keys.
rpc GetRange(RangeRequest) returns (stream KeyValueReply) {}
// PutRange stores a stream of key-value pairs. It is an error if any
// key already has a stored value.
rpc PutRange(stream PutRequest) returns (StatusReply) {}
// KeysInRange returns all keys stored within a range of keys.
rpc KeysInRange(RangeRequest) returns (KeysReply) {}
// DeleteRange deletes all key-value pairs within a range of keys in
// an asynchronous manner. Deletions can be carried off in the background
// although keys should be made invalid upon return.
rpc DeleteRange(RangeRequest) returns (StatusReply) {}
}
@DocSavage
Copy link
Author

Compared to the mutable ordered k/v store API, the immutable store has no batch transactions because there is no delete only puts, and you can only put once for a key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment