Debian Codegraph @

src/core/lib/surface/lame_client.h

raw
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_LIB_SURFACE_LAME_CLIENT_H
20 #define GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include <memory>
25
26 #include "absl/base/thread_annotations.h"
27 #include "absl/status/status.h"
28 #include "absl/status/statusor.h"
29
30 #include <grpc/impl/codegen/grpc_types.h>
31
32 #include "src/core/lib/channel/channel_args.h"
33 #include "src/core/lib/channel/channel_fwd.h"
34 #include "src/core/lib/channel/promise_based_filter.h"
35 #include "src/core/lib/gprpp/sync.h"
36 #include "src/core/lib/iomgr/error.h"
37 #include "src/core/lib/promise/arena_promise.h"
38 #include "src/core/lib/transport/connectivity_state.h"
39 #include "src/core/lib/transport/transport.h"
40
41 namespace grpc_core {
42 // Does NOT take ownership of error.
43 grpc_arg MakeLameClientErrorArg(grpc_error_handle* error);
44
45 // This filter becomes the entire channel stack for a channel that fails to be
46 // created. Every call returns failure.
47 class LameClientFilter : public ChannelFilter {
48 public:
49 static const grpc_channel_filter kFilter;
50
51 static absl::StatusOr<LameClientFilter> Create(
52 const ChannelArgs& args, ChannelFilter::Args filter_args);
53 ArenaPromise<ServerMetadataHandle> MakeCallPromise(
54 CallArgs call_args, NextPromiseFactory next_promise_factory) override;
55 bool StartTransportOp(grpc_transport_op*) override;
56 bool GetChannelInfo(const grpc_channel_info*) override;
57
58 private:
59 explicit LameClientFilter(absl::Status error);
60
61 absl::Status error_;
62 struct State {
63 State();
64 Mutex mu;
65 ConnectivityStateTracker state_tracker ABSL_GUARDED_BY(mu);
66 };
67 std::unique_ptr<State> state_;
68 };
69 } // namespace grpc_core
70
71 #endif /* GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H */