GRPC Core  18.0.0
load_balancer_api.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H
21 
23 
24 #include <vector>
25 
26 #include <grpc/slice_buffer.h>
27 
31 
32 #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128
33 #define GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE 16
34 #define GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE 50
35 
36 namespace grpc_core {
37 
38 // Contains server information. When the drop field is not true, use the other
39 // fields.
40 struct GrpcLbServer {
41  int32_t ip_size;
43  int32_t port;
45  bool drop;
46 
47  bool operator==(const GrpcLbServer& other) const;
48 };
49 
53  std::vector<GrpcLbServer> serverlist;
54 };
55 
56 // Creates a serialized grpclb request.
57 grpc_slice GrpcLbRequestCreate(const char* lb_service_name, upb_arena* arena);
58 
59 // Creates a serialized grpclb load report request.
61  int64_t num_calls_started, int64_t num_calls_finished,
62  int64_t num_calls_finished_with_client_failed_to_send,
63  int64_t num_calls_finished_known_received,
64  const GrpcLbClientStats::DroppedCallCounts* drop_token_counts,
65  upb_arena* arena);
66 
67 // Deserialize a grpclb response.
68 bool GrpcLbResponseParse(const grpc_slice& serialized_response,
69  upb_arena* arena, GrpcLbResponse* result);
70 
71 } // namespace grpc_core
72 
73 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_LOAD_BALANCER_API_H \
74  */
absl::InlinedVector< DropTokenCount, 10 > DroppedCallCounts
Definition: grpclb_client_stats.h:44
int64_t grpc_millis
Definition: exec_ctx.h:37
#define GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE
Definition: load_balancer_api.h:34
#define GRPC_GRPCLB_SERVER_IP_ADDRESS_MAX_SIZE
Definition: load_balancer_api.h:33
Round Robin Policy.
Definition: backend_metric.cc:26
bool GrpcLbResponseParse(const grpc_slice &serialized_response, upb_arena *arena, GrpcLbResponse *result)
Definition: load_balancer_api.cc:158
grpc_slice GrpcLbLoadReportRequestCreate(int64_t num_calls_started, int64_t num_calls_finished, int64_t num_calls_finished_with_client_failed_to_send, int64_t num_calls_finished_known_received, const GrpcLbClientStats::DroppedCallCounts *drop_token_counts, upb_arena *arena)
Definition: load_balancer_api.cc:75
grpc_slice GrpcLbRequestCreate(const char *lb_service_name, upb_arena *arena)
Definition: load_balancer_api.cc:54
Definition: load_balancer_api.h:50
enum grpc_core::GrpcLbResponse::@3 type
std::vector< GrpcLbServer > serverlist
Definition: load_balancer_api.h:53
grpc_millis client_stats_report_interval
Definition: load_balancer_api.h:52
@ INITIAL
Definition: load_balancer_api.h:51
@ FALLBACK
Definition: load_balancer_api.h:51
@ SERVERLIST
Definition: load_balancer_api.h:51
Definition: load_balancer_api.h:40
char load_balance_token[50]
Definition: load_balancer_api.h:44
bool drop
Definition: load_balancer_api.h:45
bool operator==(const GrpcLbServer &other) const
Definition: load_balancer_api.cc:31
int32_t ip_size
Definition: load_balancer_api.h:41
char ip_addr[16]
Definition: load_balancer_api.h:42
int32_t port
Definition: load_balancer_api.h:43
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
upb_arena * arena
Definition: xds_api.cc:909