syntax = "proto3";

package nominal.direct_channel_writer.v2;

import "nominal/protos/gen/v1/alias.proto";
import "nominal/protos/types/object_storage/handle.proto";

option java_multiple_files = true;
option java_package = "io.nominal.direct_channel_writer.v2";

// Tells the consumer how to deserialize the bytes referenced by a batch handle.
enum BatchFormat {
  BATCH_FORMAT_UNSPECIFIED = 0;
  // Bytes are a serialized direct_channel_writer.v2.InternalWriteBatchesRequest.
  BATCH_FORMAT_WRITE_BATCHES_REQUEST_PROTO = 1;
}

// Internal request used by refinery to publish parsed file data to Kafka. References
// the staged batch in object storage by handle so consumers fetch the batch directly
// instead of receiving the full payload over Kafka.
message WriteFileDataRequest {
  nominal.types.object_storage.Handle batch_handle = 1;
  string ingest_job_rid = 2 [(nominal.gen.v1.alias) = {java_name: "io.nominal.ingest.api.IngestJobRid"}];
  string dataset_file_id = 3 [(nominal.gen.v1.alias) = {java_name: "io.nominal.datasource.DatasetFileId"}];
  string org_rid = 4 [(nominal.gen.v1.alias) = {java_name: "io.nominal.authentication.api.OrgRid"}];

  int32 batch_id = 5;

  // Format of the bytes at batch_handle. Required so consumers can pick the right
  // deserializer without inspecting the object.
  BatchFormat batch_format = 7;
}
