syntax = "proto3";

package mesh.v1;

option go_package = "atlassian.com/bitbucket/mesh/rpc/v1";
option java_multiple_files = true;
option java_outer_classname = "TopologyProtos";
option java_package = "com.atlassian.bitbucket.mesh.rpc.v1";

message RpcNode {
  string id = 1;
  string name = 2;
  string rpc_url = 3;
}

message RpcNodeIdList {
  repeated string nodes = 1;
}

message RpcPartition {
  string id = 1;
  repeated RpcPartitionReplica replicas = 2;
}

message RpcPartitionReplica {
  string id = 1;
  string node_id = 2;
}

//@since 1.3
message RpcPartitionReplicaMigration {
  string partition = 1;
  string source_node_id = 2;
  string target_node_id = 3;
}

enum RpcReplicaState {
  REPLICA_STATE_UNKNOWN = 0;
  REPLICA_STATE_CONSISTENT = 1;
  REPLICA_STATE_INCONSISTENT = 2;
  REPLICA_STATE_MISSING = 3;
  REPLICA_STATE_REPAIRING = 4;
}

message RpcTopology {
  reserved 1; //For a future topology version / generation
  repeated RpcNode nodes = 2;
  repeated RpcPartition partitions = 3;
  //@since 1.3
  repeated RpcPartitionReplicaMigration partition_migrations = 4;
}
