Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_SERVICE_TYPE_H
20 #define GRPCPP_IMPL_SERVICE_TYPE_H
28 #include "absl/log/absl_check.h"
32 class CompletionQueue;
34 class ServerInterface;
52 virtual void BindCall(
Call* call) = 0;
63 for (
const auto& method : methods_) {
64 if (method && method->handler() ==
nullptr) {
72 for (
const auto& method : methods_) {
82 for (
const auto& method : methods_) {
83 if (method && (method->api_type() ==
94 for (
const auto& method : methods_) {
95 if (method ==
nullptr) {
103 template <
class Message>
113 size_t idx =
static_cast<size_t>(index);
115 notification_cq, tag, request);
122 size_t idx =
static_cast<size_t>(index);
124 notification_cq, tag);
126 template <
class Message>
132 size_t idx =
static_cast<size_t>(index);
134 notification_cq, tag, request);
141 size_t idx =
static_cast<size_t>(index);
143 notification_cq, tag);
147 methods_.emplace_back(method);
153 size_t idx =
static_cast<size_t>(index);
154 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
155 <<
"Cannot mark the method as 'async' because it has already been "
156 "marked as 'generic'.";
163 size_t idx =
static_cast<size_t>(index);
164 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
165 <<
"Cannot mark the method as 'raw' because it has already "
166 "been marked as 'generic'.";
173 size_t idx =
static_cast<size_t>(index);
174 ABSL_CHECK_NE(methods_[idx]->handler(),
nullptr)
175 <<
"Cannot mark the method as 'generic' because it has already been "
176 "marked as 'async' or 'raw'.";
177 methods_[idx].reset();
183 size_t idx =
static_cast<size_t>(index);
184 ABSL_CHECK(methods_[idx] && methods_[idx]->handler())
185 <<
"Cannot mark an async or generic method Streamed";
186 methods_[idx]->SetHandler(streamed_method);
198 size_t idx =
static_cast<size_t>(index);
199 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
200 <<
"Cannot mark the method as 'callback' because it has already been "
201 "marked as 'generic'.";
202 methods_[idx]->SetHandler(handler);
203 methods_[idx]->SetServerApiType(
210 size_t idx =
static_cast<size_t>(index);
211 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
212 <<
"Cannot mark the method as 'raw callback' because it has already "
213 "been marked as 'generic'.";
214 methods_[idx]->SetHandler(handler);
215 methods_[idx]->SetServerApiType(
220 size_t idx =
static_cast<size_t>(index);
221 return methods_[idx]->handler();
228 std::vector<std::unique_ptr<internal::RpcServiceMethod>> methods_;
233 #endif // GRPCPP_IMPL_SERVICE_TYPE_H
void RequestAsyncUnary(int index, grpc::ServerContext *context, Message *request, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:104
bool has_callback_methods() const
Definition: service_type.h:81
Definition: service_type.h:38
void MarkMethodRaw(int index)
Definition: service_type.h:160
void MarkMethodAsync(int index)
Definition: service_type.h:150
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:578
Represents a gRPC server.
Definition: server.h:57
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
virtual ~Service()
Definition: service_type.h:60
internal::MethodHandler * GetHandler(int index)
Definition: service_type.h:219
bool has_generic_methods() const
Definition: service_type.h:93
void RequestAsyncBidiStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:136
Straightforward wrapping of the C call object.
Definition: call.h:36
Descriptor of an RPC service and its various RPC methods.
Definition: service_type.h:57
void MarkMethodCallback(int index, internal::MethodHandler *handler)
Definition: service_type.h:195
@ BIDI_STREAMING
Definition: rpc_method.h:35
void MarkMethodGeneric(int index)
Definition: service_type.h:170
void AddMethod(internal::RpcServiceMethod *method)
Definition: service_type.h:146
bool has_synchronous_methods() const
Definition: service_type.h:71
void MarkMethodStreamed(int index, internal::MethodHandler *streamed_method)
Definition: service_type.h:180
virtual void SendInitialMetadata(void *tag)=0
Request notification of the sending of initial metadata to the client.
void RequestAsyncServerStreaming(int index, grpc::ServerContext *context, Message *request, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:127
Base class for running an RPC handler.
Definition: rpc_service_method.h:40
void RequestAsyncCall(internal::RpcServiceMethod *method, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag, Message *message)
Definition: server_interface.h:316
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:426
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
Server side rpc method class.
Definition: rpc_service_method.h:86
bool has_async_methods() const
Definition: service_type.h:62
void MarkMethodRawCallback(int index, internal::MethodHandler *handler)
Definition: service_type.h:207
Definition: server_interface.h:60
::google::protobuf::Message Message
Definition: config_protobuf.h:89
void RequestAsyncClientStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:117
virtual ~ServerAsyncStreamingInterface()
Definition: service_type.h:40
Service()
Definition: service_type.h:59