package storagepb;

import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_enum_prefix_all) = false;

message KeyValue {
  optional bytes key = 1 [(gogoproto.nullable) = false];
  // mod_index is the last modified index of the key.
  optional int64 create_index = 2 [(gogoproto.nullable) = false];
  optional int64 mod_index = 3 [(gogoproto.nullable) = false];
  // version is the version of the key. A deletion resets
  // the version to zero and any modification of the key
  // increases its version.
  optional int64 version = 4 [(gogoproto.nullable) = false];
  optional bytes value = 5 [(gogoproto.nullable) = false];
}

message Event {
  enum EventType {
    PUT = 0;
    DELETE = 1;
    EXPIRE = 2;
  }
  optional EventType type = 1 [(gogoproto.nullable) = false];
  // a put event contains the current key-value
  // a delete/expire event contains the previous
  // key-value
  optional KeyValue kv = 2 [(gogoproto.nullable) = false];
}

