Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_SERVICE_TYPE_H
20 #define GRPCPP_IMPL_SERVICE_TYPE_H
22 #include "absl/log/absl_check.h"
33 class CompletionQueue;
35 class ServerInterface;
53 virtual void BindCall(
Call* call) = 0;
64 for (
const auto& method : methods_) {
65 if (method && method->handler() ==
nullptr) {
73 for (
const auto& method : methods_) {
83 for (
const auto& method : methods_) {
84 if (method && (method->api_type() ==
95 for (
const auto& method : methods_) {
96 if (method ==
nullptr) {
104 template <
class Message>
114 size_t idx =
static_cast<size_t>(index);
116 notification_cq, tag, request);
123 size_t idx =
static_cast<size_t>(index);
125 notification_cq, tag);
127 template <
class Message>
133 size_t idx =
static_cast<size_t>(index);
135 notification_cq, tag, request);
142 size_t idx =
static_cast<size_t>(index);
144 notification_cq, tag);
148 methods_.emplace_back(method);
154 size_t idx =
static_cast<size_t>(index);
155 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
156 <<
"Cannot mark the method as 'async' because it has already been "
157 "marked as 'generic'.";
164 size_t idx =
static_cast<size_t>(index);
165 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
166 <<
"Cannot mark the method as 'raw' because it has already "
167 "been marked as 'generic'.";
174 size_t idx =
static_cast<size_t>(index);
175 ABSL_CHECK_NE(methods_[idx]->handler(),
nullptr)
176 <<
"Cannot mark the method as 'generic' because it has already been "
177 "marked as 'async' or 'raw'.";
178 methods_[idx].reset();
184 size_t idx =
static_cast<size_t>(index);
185 ABSL_CHECK(methods_[idx] && methods_[idx]->handler())
186 <<
"Cannot mark an async or generic method Streamed";
187 methods_[idx]->SetHandler(streamed_method);
199 size_t idx =
static_cast<size_t>(index);
200 ABSL_CHECK_NE(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);
212 ABSL_CHECK_NE(methods_[idx].get(),
nullptr)
213 <<
"Cannot mark the method as 'raw callback' because it has already "
214 "been marked as 'generic'.";
215 methods_[idx]->SetHandler(handler);
216 methods_[idx]->SetServerApiType(
221 size_t idx =
static_cast<size_t>(index);
222 return methods_[idx]->handler();
229 std::vector<std::unique_ptr<internal::RpcServiceMethod>> methods_;
234 #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:105
bool has_callback_methods() const
Definition: service_type.h:82
Definition: service_type.h:39
void MarkMethodRaw(int index)
Definition: service_type.h:161
void MarkMethodAsync(int index)
Definition: service_type.h:151
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:61
internal::MethodHandler * GetHandler(int index)
Definition: service_type.h:220
bool has_generic_methods() const
Definition: service_type.h:94
void RequestAsyncBidiStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:137
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:58
void MarkMethodCallback(int index, internal::MethodHandler *handler)
Definition: service_type.h:196
@ BIDI_STREAMING
Definition: rpc_method.h:35
void MarkMethodGeneric(int index)
Definition: service_type.h:171
void AddMethod(internal::RpcServiceMethod *method)
Definition: service_type.h:147
bool has_synchronous_methods() const
Definition: service_type.h:72
void MarkMethodStreamed(int index, internal::MethodHandler *streamed_method)
Definition: service_type.h:181
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:128
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:317
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:427
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:105
Server side rpc method class.
Definition: rpc_service_method.h:86
bool has_async_methods() const
Definition: service_type.h:63
void MarkMethodRawCallback(int index, internal::MethodHandler *handler)
Definition: service_type.h:208
Definition: server_interface.h:61
::google::protobuf::Message Message
Definition: config_protobuf.h:88
void RequestAsyncClientStreaming(int index, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
Definition: service_type.h:118
virtual ~ServerAsyncStreamingInterface()
Definition: service_type.h:41
Service()
Definition: service_type.h:60