syntax = "proto3";

package clusterapi;

enum CompressionType {
  COMPRESSION_TYPE_UNSPECIFIED = 0;     // No compression
  COMPRESSION_TYPE_GZIP = 1;     // gzip (compress/gzip)
  COMPRESSION_TYPE_ZLIB = 2;     // zlib (compress/zlib)
  COMPRESSION_TYPE_DEFLATE = 3;  // raw DEFLATE (compress/flate)
}

service FileReplicationService {
  rpc PauseFileActivity (PauseFileActivityRequest) returns (PauseFileActivityResponse);

  rpc ResumeFileActivity (ResumeFileActivityRequest) returns (ResumeFileActivityResponse);

  rpc ListFiles (ListFilesRequest) returns (ListFilesResponse);

  rpc GetFileMetadata (GetFileMetadataRequest) returns (FileMetadata);

  rpc GetFile (GetFileRequest) returns (stream FileChunk);
}

message PauseFileActivityRequest {
  string index_name = 1;
  string shard_name = 2;
  uint64 schema_version = 3;
}

message PauseFileActivityResponse {
  string index_name = 1;
  string shard_name = 2;
}

message ResumeFileActivityRequest {
  string index_name = 1;
  string shard_name = 2;
}

message ResumeFileActivityResponse {
  string index_name = 1;
  string shard_name = 2;
}

message ListFilesRequest {
  string index_name = 1;
  string shard_name = 2;
}

message ListFilesResponse {
  string index_name = 1;
  string shard_name = 2;
  repeated string file_names = 3;
}

message GetFileMetadataRequest {
  string index_name = 1;
  string shard_name = 2;
  string file_name = 3;
}

message FileMetadata {
  string index_name = 1;
  string shard_name = 2;
  string file_name = 3;
  int64 size = 4;
  uint32 crc32 = 5;
}

message GetFileRequest {
  string index_name = 1;
  string shard_name = 2;
  string file_name = 3;
  CompressionType compression = 4; // Requested compression algorithm for streamed chunks
}

message FileChunk {
  int64 offset = 1; // Byte offset in the uncompressed file
  bytes data = 2; // Compressed or raw chunk data
  bool eof = 3; // Indicates final chunk
}
