// Object Manager protocol specification
namespace ray.object_manager.protocol;

// Object information data structure.
// NOTE(pcm): This structure is replicated in
// https://github.com/apache/arrow/blob/master/cpp/src/plasma/format/common.fbs,
// so if you modify it, you should also modify that one.
table ObjectInfo {
  // Object ID of this object.
  object_id: string;
  // Number of bytes the content of this object occupies in memory.
  data_size: long;
  // Number of bytes the metadata of this object occupies in memory.
  metadata_size: long;
  // Number of clients using the objects.
  ref_count: int;
  // Unix epoch of when this object was created.
  create_time: long;
  // How long creation of this object took.
  construct_duration: long;
  // Hash of the object content. If the object is not sealed yet this is
  // an empty string.
  digest: string;
  // Specifies if this object was deleted or added.
  is_deletion: bool;
}

enum MessageType:int {
  ConnectClient = 1,
  PushRequest,
  PullRequest,
  FreeRequest
}

table PushRequestMessage {
  // The object ID being transferred.
  object_id: string;
  // The index of the chunk being transferred.
  chunk_index: ulong;
  // The total size of the object + metadata.
  data_size: ulong;
  // The metadata size.
  metadata_size: ulong;
}

table PullRequestMessage {
  // ID of the requesting client.
  client_id: string;
  // Requested ObjectID.
  object_id: string;
}

table ConnectClientMessage {
  // ID of the connecting client.
  client_id: string;
  // Whether this is a transfer connection.
  is_transfer: bool;
}

table FreeRequestMessage {
  // List of IDs to be deleted.
  object_ids: [string];
}
