syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/sink/v1";

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


package sink.v1;

service Sink {
  // SinkFn writes the request to a user defined sink.
  rpc SinkFn(stream SinkRequest) returns (SinkResponse);

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

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

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

/**
 * SinkResponse is the individual response of each message written to the sink.
 */
message SinkResponse {
  message Result {
    // id is the ID of the message, can be used to uniquely identify the message.
    string id = 1;
    // success denotes the status of persisting to disk. if set to false, it means writing to sink for the message failed.
    bool success = 2;
    // err_msg is the error message, set it if success is set to false.
    string err_msg = 3;
  }
  repeated Result results = 1;
}