GRPC C++  1.66.0
callback_generic_service.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2024 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 GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
20 #define GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
21 
26 
27 struct grpc_server;
28 
29 namespace grpc {
30 
35 
37  public:
38  const std::string& method() const { return method_; }
39  const std::string& host() const { return host_; }
40 
41  private:
42  friend class grpc::Server;
43 
44  std::string method_;
45  std::string host_;
46 };
47 
52  public:
55 
61  class Reactor : public ServerGenericBidiReactor {
62  public:
63  Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); }
64  void OnDone() override { delete this; }
65  };
66  return new Reactor;
67  }
68 
69  private:
70  friend class grpc::Server;
71 
74  [this](grpc::CallbackServerContext* ctx) {
75  return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx));
76  });
77  }
78 
79  grpc::Server* server_{nullptr};
80 };
81 
82 } // namespace grpc
83 
84 #endif // GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
grpc::Server
Represents a gRPC server.
Definition: server.h:57
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::CallbackServerContext
Definition: server_context.h:618
grpc::GenericCallbackServerContext::host
const std::string & host() const
Definition: callback_generic_service.h:39
grpc::ServerBidiReactor
ServerBidiReactor is the interface for a bidirectional streaming RPC.
Definition: server_callback.h:195
grpc_server
struct grpc_server grpc_server
A server listens to some port and responds to request calls.
Definition: grpc_types.h:64
grpc::CallbackGenericService::CallbackGenericService
CallbackGenericService()
Definition: callback_generic_service.h:53
server_callback.h
grpc::internal::CallbackBidiHandler
Definition: server_callback_handlers.h:677
grpc::UNIMPLEMENTED
@ UNIMPLEMENTED
Operation is not implemented or not supported/enabled in this service.
Definition: status_code_enum.h:117
byte_buffer.h
grpc::GenericCallbackServerContext
Definition: callback_generic_service.h:36
server_callback_handlers.h
grpc::GenericCallbackServerContext::method
const std::string & method() const
Definition: callback_generic_service.h:38
grpc::CallbackGenericService::CreateReactor
virtual ServerGenericBidiReactor * CreateReactor(GenericCallbackServerContext *)
The "method handler" for the generic API.
Definition: callback_generic_service.h:59
grpc::protobuf::util::Status
::absl::Status Status
Definition: config_protobuf.h:106
grpc::CallbackGenericService::~CallbackGenericService
virtual ~CallbackGenericService()
Definition: callback_generic_service.h:54
grpc::CallbackGenericService
CallbackGenericService is the base class for generic services implemented using the callback API and ...
Definition: callback_generic_service.h:51
port_platform.h