aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/proto/grpc/lb/v1/load_balancer.proto
blob: c9932bcf60b2ad99a2b71586559e4317ef8b0425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright 2015 The gRPC 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.

// This file defines the GRPCLB LoadBalancing protocol.
//
// The canonical version of this proto can be found at
// https://github.com/grpc/grpc-proto/blob/master/grpc/lb/v1/load_balancer.proto
syntax = "proto3";

package grpc.lb.v1;

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

option go_package = "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1";
option java_multiple_files = true;
option java_outer_classname = "LoadBalancerProto";
option java_package = "io.grpc.grpclb";

service LoadBalancer {
  // Bidirectional rpc to get a list of servers.
  rpc BalanceLoad(stream LoadBalanceRequest) returns (stream LoadBalanceResponse);
}

message LoadBalanceRequest {
  oneof load_balance_request_type {
    // This message should be sent on the first request to the load balancer.
    InitialLoadBalanceRequest initial_request = 1;

    // The client stats should be periodically reported to the load balancer
    // based on the duration defined in the InitialLoadBalanceResponse.
    ClientStats client_stats = 2;
  }
}

message InitialLoadBalanceRequest {
  // The name of the load balanced service (e.g., service.googleapis.com). Its
  // length should be less than 256 bytes.
  // The name might include a port number. How to handle the port number is up
  // to the balancer.
  string name = 1;
}

// Contains the number of calls finished for a particular load balance token.
message ClientStatsPerToken {
  // See Server.load_balance_token.
  string load_balance_token = 1;

  // The total number of RPCs that finished associated with the token.
  int64 num_calls = 2;
}

// Contains client level statistics that are useful to load balancing. Each
// count except the timestamp should be reset to zero after reporting the stats.
message ClientStats {
  // The timestamp of generating the report.
  google.protobuf.Timestamp timestamp = 1;

  // The total number of RPCs that started.
  int64 num_calls_started = 2;

  // The total number of RPCs that finished.
  int64 num_calls_finished = 3;

  // The total number of RPCs that failed to reach a server except dropped RPCs.
  int64 num_calls_finished_with_client_failed_to_send = 6;

  // The total number of RPCs that finished and are known to have been received
  // by a server.
  int64 num_calls_finished_known_received = 7;

  // The list of dropped calls.
  repeated ClientStatsPerToken calls_finished_with_drop = 8;

  reserved 4, 5;
}

message LoadBalanceResponse {
  oneof load_balance_response_type {
    // This message should be sent on the first response to the client.
    InitialLoadBalanceResponse initial_response = 1;

    // Contains the list of servers selected by the load balancer. The client
    // should send requests to these servers in the specified order.
    ServerList server_list = 2;
  }
}

message InitialLoadBalanceResponse {
  // This is an application layer redirect that indicates the client should use
  // the specified server for load balancing. When this field is non-empty in
  // the response, the client should open a separate connection to the
  // load_balancer_delegate and call the BalanceLoad method. Its length should
  // be less than 64 bytes.
  string load_balancer_delegate = 1;

  // This interval defines how often the client should send the client stats
  // to the load balancer. Stats should only be reported when the duration is
  // positive.
  google.protobuf.Duration client_stats_report_interval = 2;
}

message ServerList {
  // Contains a list of servers selected by the load balancer. The list will
  // be updated when server resolutions change or as needed to balance load
  // across more servers. The client should consume the server list in order
  // unless instructed otherwise via the client_config.
  repeated Server servers = 1;

  // Was google.protobuf.Duration expiration_interval.
  reserved 3;
}

// Contains server information. When the drop field is not true, use the other
// fields.
message Server {
  // A resolved address for the server, serialized in network-byte-order. It may
  // either be an IPv4 or IPv6 address.
  bytes ip_address = 1;

  // A resolved port number for the server.
  int32 port = 2;

  // An opaque but printable token for load reporting. The client must include
  // the token of the picked server into the initial metadata when it starts a
  // call to that server. The token is used by the server to verify the request
  // and to allow the server to report load to the gRPC LB system. The token is
  // also used in client stats for reporting dropped calls.
  //
  // Its length can be variable but must be less than 50 bytes.
  string load_balance_token = 3;

  // Indicates whether this particular request should be dropped by the client.
  // If the request is dropped, there will be a corresponding entry in
  // ClientStats.calls_finished_with_drop.
  bool drop = 4;

  reserved 5;
}