diff options
Diffstat (limited to 'include/grpcpp/impl/codegen/server_context.h')
-rw-r--r-- | include/grpcpp/impl/codegen/server_context.h | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index 6314364db6..82ee862f61 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -26,11 +26,14 @@ #include <grpc/impl/codegen/compression_types.h> #include <grpcpp/impl/codegen/call.h> +#include <grpcpp/impl/codegen/call_op_set.h> +#include <grpcpp/impl/codegen/callback_common.h> #include <grpcpp/impl/codegen/completion_queue_tag.h> #include <grpcpp/impl/codegen/config.h> #include <grpcpp/impl/codegen/create_auth_context.h> #include <grpcpp/impl/codegen/metadata_map.h> #include <grpcpp/impl/codegen/security/auth_context.h> +#include <grpcpp/impl/codegen/server_interceptor.h> #include <grpcpp/impl/codegen/string_ref.h> #include <grpcpp/impl/codegen/time.h> @@ -63,6 +66,8 @@ template <class ServiceType, class RequestType, class ResponseType> class ServerStreamingHandler; template <class ServiceType, class RequestType, class ResponseType> class BidiStreamingHandler; +template <class ServiceType, class RequestType, class ResponseType> +class CallbackUnaryHandler; template <class Streamer, bool WriteNeeded> class TemplatedBidiStreamingHandler; template <StatusCode code> @@ -107,7 +112,7 @@ class ServerContext { /// Return a \a gpr_timespec representation of the server call's deadline. gpr_timespec raw_deadline() const { return deadline_; } - /// Add the (\a meta_key, \a meta_value) pair to the initial metadata + /// Add the (\a key, \a value) pair to the initial metadata /// associated with a server call. These are made available at the client side /// by the \a grpc::ClientContext::GetServerInitialMetadata() method. /// @@ -115,13 +120,13 @@ class ServerContext { /// to the client (which can happen explicitly, or implicitly when sending a /// a response message or status to the client). /// - /// \param meta_key The metadata key. If \a meta_value is binary data, it must + /// \param key The metadata key. If \a value is binary data, it must /// end in "-bin". - /// \param meta_value The metadata value. If its value is binary, the key name + /// \param value The metadata value. If its value is binary, the key name /// must end in "-bin". void AddInitialMetadata(const grpc::string& key, const grpc::string& value); - /// Add the (\a meta_key, \a meta_value) pair to the initial metadata + /// Add the (\a key, \a value) pair to the initial metadata /// associated with a server call. These are made available at the client /// side by the \a grpc::ClientContext::GetServerTrailingMetadata() method. /// @@ -129,13 +134,13 @@ class ServerContext { /// metadata to the client (which happens when the call is finished and a /// status is sent to the client). /// - /// \param meta_key The metadata key. If \a meta_value is binary data, + /// \param key The metadata key. If \a value is binary data, /// it must end in "-bin". - /// \param meta_value The metadata value. If its value is binary, the key name + /// \param value The metadata value. If its value is binary, the key name /// must end in "-bin". void AddTrailingMetadata(const grpc::string& key, const grpc::string& value); - /// IsCancelled is always safe to call when using sync API. + /// IsCancelled is always safe to call when using sync or callback API. /// When using async API, it is only safe to call IsCancelled after /// the AsyncNotifyWhenDone tag has been delivered. bool IsCancelled() const; @@ -177,9 +182,9 @@ class ServerContext { return compression_level_; } - /// Set \a algorithm to be the compression algorithm used for the server call. + /// Set \a level to be the compression level used for the server call. /// - /// \param algorithm The compression algorithm used for the server call. + /// \param level The compression level used for the server call. void set_compression_level(grpc_compression_level level) { compression_level_set_ = true; compression_level_ = level; @@ -265,6 +270,8 @@ class ServerContext { friend class ::grpc::internal::ServerStreamingHandler; template <class Streamer, bool WriteNeeded> friend class ::grpc::internal::TemplatedBidiStreamingHandler; + template <class ServiceType, class RequestType, class ResponseType> + friend class ::grpc::internal::CallbackUnaryHandler; template <StatusCode code> friend class internal::ErrorMethodHandler; friend class ::grpc::ClientContext; @@ -275,7 +282,7 @@ class ServerContext { class CompletionOp; - void BeginCompletionOp(internal::Call* call); + void BeginCompletionOp(internal::Call* call, bool callback); /// Return the tag queued by BeginCompletionOp() internal::CompletionQueueTag* GetCompletionOpTag(); @@ -283,18 +290,37 @@ class ServerContext { void set_call(grpc_call* call) { call_ = call; } + void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr); + + void Clear(); + + void Setup(gpr_timespec deadline); + uint32_t initial_metadata_flags() const { return 0; } + experimental::ServerRpcInfo* set_server_rpc_info( + const char* method, + const std::vector< + std::unique_ptr<experimental::ServerInterceptorFactoryInterface>>& + creators) { + if (creators.size() != 0) { + rpc_info_ = new experimental::ServerRpcInfo(this, method); + rpc_info_->RegisterInterceptors(creators); + } + return rpc_info_; + } + CompletionOp* completion_op_; bool has_notify_when_done_tag_; void* async_notify_when_done_tag_; + internal::CallbackWithSuccessTag completion_tag_; gpr_timespec deadline_; grpc_call* call_; CompletionQueue* cq_; bool sent_initial_metadata_; mutable std::shared_ptr<const AuthContext> auth_context_; - internal::MetadataMap client_metadata_; + mutable internal::MetadataMap client_metadata_; std::multimap<grpc::string, grpc::string> initial_metadata_; std::multimap<grpc::string, grpc::string> trailing_metadata_; @@ -306,6 +332,8 @@ class ServerContext { internal::CallOpSendMessage> pending_ops_; bool has_pending_ops_; + + experimental::ServerRpcInfo* rpc_info_; }; } // namespace grpc |