syntax = "proto3";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";


package reduce.v1;

service Reduce {
  // ReduceFn applies a reduce function to a request stream.
  rpc ReduceFn(stream ReduceRequest) returns (stream ReduceResponse);

  // IsReady is the heartbeat endpoint for gRPC.
  rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
 * ReduceRequest represents a request element.
 */
message ReduceRequest {
  repeated string keys = 1;
  bytes value = 2;
  google.protobuf.Timestamp event_time = 3;
  google.protobuf.Timestamp watermark = 4;
}

/**
 * ReduceResponse represents a response element.
 */
message ReduceResponse {
  message Result {
    repeated string keys = 1;
    bytes value = 2;
    repeated string tags = 3;
  }
  repeated Result results = 1;
}

/**
 * ReadyResponse is the health check result.
 */
message ReadyResponse {
  bool ready = 1;
}