/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

package dapr.proto.placement.v1;

option go_package = "github.com/dapr/dapr/pkg/proto/placement/v1;placement";

// Placement service is used to report Dapr runtime host status.
service Placement {
  // Reports Dapr actor status and retrieves actor placement table.
  rpc ReportDaprStatus(stream Host) returns (stream PlacementOrder) {}
}

message PlacementOrder {
  PlacementTables tables = 1;
  string operation = 2;
}

message PlacementTables {
  map<string, PlacementTable> entries = 1;
  string version = 2;
  // Minimum observed version of the Actor APIs supported by connected runtimes
  uint32 api_level = 3;
  int64 replication_factor = 4;
}

message PlacementTable {
  map<uint64, string> hosts = 1;
  repeated uint64 sorted_set = 2;
  map<string, Host> load_map = 3;
  int64 total_load = 4;
}

message Host {
  string name = 1;
  int64 port = 2;
  int64 load = 3;
  repeated string entities = 4;
  string id = 5;
  string pod = 6;
  // Version of the Actor APIs supported by the Dapr runtime
  uint32 api_level = 7;
  string namespace = 8;
}
