syntax = "proto3";
package wal_log;

message LogOffset {
    uint64 next_offset = 1;
}

message HelloRequest {
    optional uint64 handshake_version = 1;
}

message HelloResponse {
    /// Uuid of the current generation
    string generation_id = 1;
    /// First frame_no in the current generation
    uint64 generation_start_index = 2;
    /// id of the replicated log
    string log_id = 3;
    /// string-encoded Uuid v4 token for the current session, changes on each restart, and must be passed in subsequent requests header.string
    /// If the header session token fails to match the current session token, a NO_HELLO error is returned
    bytes session_token = 4;
    optional uint64 current_replication_index = 5;
}

message Frame {
    bytes data = 1;
}

message Frames {
    repeated Frame frames = 1;
}

service ReplicationLog {
    rpc Hello(HelloRequest) returns (HelloResponse) {}
    rpc LogEntries(LogOffset) returns (stream Frame) {}
    rpc BatchLogEntries(LogOffset) returns (Frames) {}
    rpc Snapshot(LogOffset) returns (stream Frame) {}
}