agones.dev/agones@v1.53.0/sdks/rust/proto/allocation/allocation.proto (about)

     1  // Copyright 2020 Google LLC All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  syntax = "proto3";
    16  
    17  package allocation;
    18  option go_package = "./allocation";
    19  
    20  import "google/api/annotations.proto";
    21  import "google/protobuf/wrappers.proto";
    22  import "protoc-gen-openapiv2/options/annotations.proto";
    23  
    24  option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
    25    info: {
    26      title: "proto/allocation/allocation.proto";
    27      version: "version not set";
    28    };
    29    schemes: HTTPS;
    30    consumes: "application/json";
    31    produces: "application/json";
    32  };
    33  
    34  service AllocationService {
    35    rpc Allocate(AllocationRequest) returns (AllocationResponse) {
    36      option (google.api.http) = {
    37        post: "/gameserverallocation"
    38        body: "*"
    39      };
    40    }
    41  }
    42  
    43  message AllocationRequest {
    44    // The k8s namespace that is hosting the targeted fleet of gameservers to be allocated
    45    string namespace = 1;
    46  
    47    // If specified, multi-cluster policies are applied. Otherwise, allocation will happen locally.
    48    MultiClusterSetting multiClusterSetting = 2;
    49  
    50    // Deprecated: Please use gameServerSelectors instead. This field is ignored if the
    51    // gameServerSelectors field is set
    52    // The required allocation. Defaults to all GameServers.
    53    GameServerSelector requiredGameServerSelector = 3 [deprecated = true];
    54  
    55    // Deprecated: Please use gameServerSelectors instead. This field is ignored if the
    56    // gameServerSelectors field is set
    57    // The ordered list of preferred allocations out of the `required` set.
    58    // If the first selector is not matched, the selection attempts the second selector, and so on.
    59    repeated GameServerSelector preferredGameServerSelectors = 4 [deprecated = true];
    60  
    61    // Scheduling strategy. Defaults to "Packed".
    62    SchedulingStrategy scheduling = 5;
    63    enum SchedulingStrategy {
    64      Packed = 0;
    65      Distributed = 1;
    66    }
    67  
    68    // Deprecated: Please use metadata instead. This field is ignored if the
    69    // metadata field is set
    70    MetaPatch metaPatch = 6;
    71  
    72    // Metadata is optional custom metadata that is added to the game server at
    73    // allocation. You can use this to tell the server necessary session data
    74    MetaPatch metadata = 7;
    75  
    76    // Ordered list of GameServer label selectors.
    77    // If the first selector is not matched, the selection attempts the second selector, and so on.
    78    // This is useful for things like smoke testing of new game servers.
    79    // Note: This field can only be set if neither Required or Preferred is set.
    80    repeated GameServerSelector gameServerSelectors = 8;
    81  
    82    // [Stage: Beta]
    83    // [FeatureFlag:CountsAndLists]
    84    // `Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.
    85    //
    86    // Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
    87    //
    88    // For `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal
    89    // infrastructure usage while also allowing some custom prioritisation of `GameServers`.
    90    //
    91    // For `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the
    92    // order that `GameServers` will be allocated by.
    93    repeated Priority priorities = 9;
    94  
    95    // [Stage: Beta]
    96    // [FeatureFlag:CountsAndLists]
    97    // Counters and Lists provide a set of actions to perform
    98    // on Counters and Lists during allocation.
    99    map<string, CounterAction> counters = 10;
   100    map<string, ListAction> lists = 11;
   101  }
   102  
   103  message AllocationResponse {
   104    string gameServerName = 2;
   105    repeated GameServerStatusPort ports = 3;
   106  
   107    // Primary address at which game server can be reached
   108    string address = 4;
   109  
   110    // All addresses at which game server can be reached; copy of Node.Status.addresses
   111    repeated GameServerStatusAddress addresses = 8;
   112  
   113    string nodeName = 5;
   114    string source = 6;
   115    optional GameServerMetadata metadata = 7;
   116  
   117    // (Beta, CountsAndLists feature flag) Status of Counters and Lists on allocation.
   118    map<string, CounterStatus> counters = 9;
   119    map<string, ListStatus> lists = 10;
   120  
   121    // The gameserver port info that is allocated.
   122    message GameServerStatusPort {
   123      string name = 1;
   124      int32 port = 2;
   125    }
   126  
   127    // A single address; identical to corev1.NodeAddress
   128    message GameServerStatusAddress {
   129      string type = 1;
   130      string address = 2;
   131    }
   132  
   133    message GameServerMetadata {
   134      map<string, string> labels = 1;
   135      map<string, string> annotations = 2;
   136    }
   137  
   138    message CounterStatus {
   139      google.protobuf.Int64Value count = 1;
   140      google.protobuf.Int64Value capacity = 2;
   141    }
   142  
   143    message ListStatus {
   144      repeated string values = 1;
   145      google.protobuf.Int64Value capacity = 2;
   146    }
   147  }
   148  
   149  // Specifies settings for multi-cluster allocation.
   150  message MultiClusterSetting {
   151    // If set to true, multi-cluster allocation is enabled.
   152    bool enabled = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {format: "boolean"}];
   153  
   154    // Selects multi-cluster allocation policies to apply. If not specified, all multi-cluster allocation policies are to be applied.
   155    LabelSelector policySelector = 2;
   156  }
   157  
   158  // MetaPatch is the metadata used to patch the GameServer metadata on allocation
   159  message MetaPatch {
   160    map<string, string> labels = 1;
   161    map<string, string> annotations = 2;
   162  }
   163  
   164  // LabelSelector used for finding a GameServer with matching labels.
   165  message LabelSelector {
   166    // Labels to match.
   167    map<string, string> matchLabels = 1;
   168  }
   169  
   170  // GameServerSelector used for finding a GameServer with matching filters.
   171  message GameServerSelector {
   172    // Labels to match.
   173    map<string, string> matchLabels = 1;
   174    enum GameServerState {
   175      READY = 0;
   176      ALLOCATED = 1;
   177    };
   178    GameServerState gameServerState = 2;
   179    PlayerSelector players = 3;
   180    map<string, CounterSelector> counters = 4;
   181    map<string, ListSelector> lists = 5;
   182  }
   183  
   184  // PlayerSelector is filter for player capacity values.
   185  // minAvailable should always be less or equal to maxAvailable.
   186  message PlayerSelector {
   187    uint64 minAvailable = 1;
   188    uint64 maxAvailable = 2;
   189  }
   190  
   191  // CounterSelector is the filter options for a GameServer based on the count and/or available capacity.
   192  // 0 for MaxCount or MaxAvailable means unlimited maximum. Default for all fields: 0
   193  message CounterSelector {
   194    int64 minCount = 1;
   195    int64 maxCount = 2;
   196    int64 minAvailable = 3;
   197    int64 maxAvailable = 4;
   198  }
   199  
   200  // ListSelector is the filter options for a GameServer based on List available capacity and/or the
   201  // existence of a value in a List.
   202  // 0 for MaxAvailable means unlimited maximum. Default for integer fields: 0
   203  // "" for ContainsValue means ignore field. Default for string field: ""
   204  message ListSelector {
   205    string containsValue = 1;
   206    int64 minAvailable = 2;
   207    int64 maxAvailable = 3;
   208  }
   209  
   210  // Priority is a sorting option for GameServers with Counters or Lists based on the Capacity.
   211  // Type: Sort by a "Counter" or a "List".
   212  // Key: The name of the Counter or List. If not found on the GameServer, has no impact.
   213  // Order: Sort by "Ascending" or "Descending". "Descending" a bigger Capacity is preferred.
   214  // "Ascending" would be smaller Capacity is preferred.
   215  message Priority {
   216    enum Type {
   217      Counter = 0;
   218      List = 1;
   219    }
   220    Type type = 1;
   221    string key = 2;
   222    enum Order {
   223      Ascending = 0;
   224      Descending = 1;
   225    }
   226    Order order = 3;
   227  }
   228  
   229  // CounterAction is an optional action that can be performed on a Counter at allocation.
   230  // Action: "Increment" or "Decrement" the Counter's Count (optional). Must also define the Amount.
   231  // Amount: The amount to increment or decrement the Count (optional). Must be a positive integer.
   232  // Capacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max int64.
   233  message CounterAction {
   234    google.protobuf.StringValue action = 1;
   235    google.protobuf.Int64Value amount = 2;
   236    google.protobuf.Int64Value capacity = 3;
   237  }
   238  
   239  // ListAction is an optional action that can be performed on a List at allocation.
   240  // AddValues: Append values to a List's Values array (optional). Any duplicate values will be ignored.
   241  // Capacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max 1000.
   242  // DeleteValues: Remove values from a List's Values array (optional). Any nonexistant values will be ignored.
   243  message ListAction {
   244    repeated string addValues = 1;
   245    google.protobuf.Int64Value capacity = 2;
   246    repeated string deleteValues = 3;
   247  }