Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_SERVICE_TYPE_H
20 #define GRPCPP_IMPL_SERVICE_TYPE_H
31 class CompletionQueue;
33 class ServerInterface;
51 virtual void BindCall(
Call* call) = 0;
62 for (
const auto& method : methods_) {
63 if (method && method->handler() ==
nullptr) {
71 for (
const auto& method : methods_) {
81 for (
const auto& method : methods_) {
82 if (method && (method->api_type() ==
93 for (
const auto& method : methods_) {
94 if (method ==
nullptr) {
102 template <
class Message>
112 size_t idx =
static_cast<size_t>(index);
114 notification_cq, tag, request);
121 size_t idx =
static_cast<size_t>(index);
123 notification_cq, tag);
125 template <
class Message>
131 size_t idx =
static_cast<size_t>(index);
133 notification_cq, tag, request);
140 size_t idx =
static_cast<size_t>(index);
142 notification_cq, tag);
146 methods_.emplace_back(method);
152 size_t idx =
static_cast<size_t>(index);
154 "Cannot mark the method as 'async' because it has already been "
155 "marked as 'generic'.");
162 size_t idx =
static_cast<size_t>(index);
164 "Cannot mark the method as 'raw' because it has already "
165 "been marked as 'generic'.");
172 size_t idx =
static_cast<size_t>(index);
174 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 GPR_ASSERT(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);
200 methods_[idx].get() !=
nullptr &&
201 "Cannot mark the method as 'callback' because it has already been "
202 "marked as 'generic'.");
203 methods_[idx]->SetHandler(handler);
204 methods_[idx]->SetServerApiType(
211 size_t idx =
static_cast<size_t>(index);
213 methods_[idx].get() !=
nullptr &&
214 "Cannot mark the method as 'raw callback' because it has already "
215 "been marked as 'generic'.");
216 methods_[idx]->SetHandler(handler);
217 methods_[idx]->SetServerApiType(
222 size_t idx =
static_cast<size_t>(index);
223 return methods_[idx]->handler();
230 std::vector<std::unique_ptr<internal::RpcServiceMethod>> methods_;
235 #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:103
bool has_callback_methods() const
Definition: service_type.h:80
Definition: service_type.h:37
void MarkMethodRaw(int index)
Definition: service_type.h:159
void MarkMethodAsync(int index)
Definition: service_type.h:149
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:573
Represents a gRPC server.
Definition: server.h:58
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:59
internal::MethodHandler * GetHandler(int index)
Definition: service_type.h:221
bool has_generic_methods() const
Definition: service_type.h:92
void RequestAsyncBidiStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:135
Straightforward wrapping of the C call object.
Definition: call.h:36
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:95
Descriptor of an RPC service and its various RPC methods.
Definition: service_type.h:56
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:169
void AddMethod(internal::RpcServiceMethod *method)
Definition: service_type.h:145
bool has_synchronous_methods() const
Definition: service_type.h:70
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:126
Base class for running an RPC handler.
Definition: rpc_service_method.h:38
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:425
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:103
Server side rpc method class.
Definition: rpc_service_method.h:84
bool has_async_methods() const
Definition: service_type.h:61
void MarkMethodRawCallback(int index, internal::MethodHandler *handler)
Definition: service_type.h:208
Definition: server_interface.h:60
::google::protobuf::Message Message
Definition: config_protobuf.h:82
void RequestAsyncClientStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:116
virtual ~ServerAsyncStreamingInterface()
Definition: service_type.h:39
Service()
Definition: service_type.h:58