syntax = "proto3";

package io.apicurio.registry.streams.distore.proto;

option java_package = "io.apicurio.registry.streams.distore.proto";
option java_multiple_files = true;

// common requests

message VoidReq {
    string storeName = 1;
}

// common responses

message Key {
    bytes key = 1;
}

message Value {
    bytes value = 1;
}

message Size {
    int64 Size = 1;
}

// KeyValueStore

service KeyValueStore {
    //    Iterator<K> allKeys();
    rpc allKeys (VoidReq) returns (stream Key) {
    }

    //    KeyValueIterator<K, V> filter(String filter);
    rpc filter (FilterReq) returns (stream KeyValue) {
    }

    //    V get(K key);
    rpc get (KeyReq) returns (stream Value) {
    }

    //    KeyValueIterator<K, V> range(K from, K to);
    rpc range (KeyFromKeyToReq) returns (stream KeyValue) {
    }

    //    KeyValueIterator<K, V> all();
    rpc all (VoidReq) returns (stream KeyValue) {
    }

    //    long approximateNumEntries();
    rpc approximateNumEntries (VoidReq) returns (Size) {
    }
}

// KeyValueStore requests

message FilterReq {
    string filter = 1;
    string over = 2;
    string storeName = 3;
}

message KeyReq {
    bytes key = 1;
    string storeName = 2;
}

message KeyFromKeyToReq {
    bytes keyFrom = 1;
    bytes keyTo = 2;
    string storeName = 3;
}

// KeyValueStore responses

message KeyValue {
    bytes key = 1;
    bytes value = 2;
}
