package bitbrew;
syntax = "proto3";
import "google/protobuf/timestamp.proto";

message DipId {
    string destinationId = 1;
    int32 partition = 2;
}

message BatchedRecord {
    string eventId = 1;
    string deviceId = 2;
    string ruleId = 3;
    Timestamp ingestionTimestamp = 4;
    string payload = 5;
    bool shouldProcess = 6;
}

message RetryBatch {
    DipId dipId = 1;
    repeated BatchedRecord records = 2;
    int64 sequenceNumber = 3;
    int32 retryCount = 4;
    int64 clearingTopicOffset = 5;
    google.protobuf.Timestamp liveSendAt = 6;
    google.protobuf.Timestamp retryAfter = 7;
}

message ClearingBatch {
    DipId dipId = 1;
    repeated BatchedRecord records = 2;
    int64 sequenceNumber = 3;
    int32 retryCount = 4;
    int64 clearingTopicOffset = 5;
    google.protobuf.Timestamp liveSendAt = 6;
    google.protobuf.Timestamp retryAfter = 7;
}

message ClosingBatch {
    DipId dipId = 1;
}

message ClearingCommittedBatch {
  DipId dipId = 1;
  int64 sequenceNumber = 2;
  int64 clearingTopicOffset = 3;
  int32 recordsSent = 4;
}

message BatchLike {
    oneof batchLike {
        RetryBatch retryBatch = 1;
        ClearingBatch clearingBatch = 2;
        ClosingBatch closingBatch = 3;
        ClearingCommittedBatch clearingCommittedBatch = 4;
    }
}
