xref: /aosp_15_r20/external/grpc-grpc/src/core/load_balancing/health_check_client.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 //
2 // Copyright 2022 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_H
18 #define GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_H
19 
20 #include <grpc/support/port_platform.h>
21 
22 #include <memory>
23 
24 #include "src/core/lib/channel/channel_args.h"
25 #include "src/core/lib/gprpp/work_serializer.h"
26 #include "src/core/load_balancing/subchannel_interface.h"
27 
28 namespace grpc_core {
29 
30 // Interface for LB policies to access health check data from a subchannel.
31 // The data is reported from via a Health.Watch stream established on the
32 // subchannel whenever an LB policy registers a watcher.
33 //
34 // To use this, an LB policy will implement its own subclass of
35 // SubchannelInterface::ConnectivityStateWatcherInterface, which will
36 // receive connectivity state updates with health check status taken
37 // into account.  It will then register that watcher with the subchannel
38 // like this:
39 //   subchannel->AddDataWatcher(
40 //       MakeHealthCheckWatcher(
41 //           work_serializer(), channel_args,
42 //           std::make_unique<MyConnectivityStateWatcherSubclass>(...)));
43 
44 std::unique_ptr<SubchannelInterface::DataWatcherInterface>
45 MakeHealthCheckWatcher(
46     std::shared_ptr<WorkSerializer> work_serializer, const ChannelArgs& args,
47     std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
48         watcher);
49 
50 }  // namespace grpc_core
51 
52 #endif  // GRPC_SRC_CORE_LOAD_BALANCING_HEALTH_CHECK_CLIENT_H
53