diff options
author | Yang Gao <yangg@google.com> | 2015-04-16 14:04:20 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-04-16 14:04:20 -0700 |
commit | b12dc6b5bc448d58bc726c7f36ae9eecc8e4741b (patch) | |
tree | 5cf6e58ee417f5bfb8c84ddbf160869e7e902551 /include | |
parent | cd1c1dd7af2e2773770af864303ba27847df081a (diff) | |
parent | 277d3cff7e07c8cc480a58edc972337b93503030 (diff) |
Merge pull request #1261 from ctiller/registered_calls
Registered calls
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/channel_interface.h | 1 | ||||
-rw-r--r-- | include/grpc++/impl/internal_stub.h | 9 | ||||
-rw-r--r-- | include/grpc++/impl/rpc_method.h | 10 | ||||
-rw-r--r-- | include/grpc++/impl/rpc_service_method.h | 2 | ||||
-rw-r--r-- | include/grpc/grpc.h | 22 |
5 files changed, 25 insertions, 19 deletions
diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel_interface.h index 7d50b45280..4d48974e69 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel_interface.h @@ -51,6 +51,7 @@ class ChannelInterface : public CallHook { public: virtual ~ChannelInterface() {} + virtual void *RegisterMethod(const char *method_name) = 0; virtual Call CreateCall(const RpcMethod& method, ClientContext* context, CompletionQueue* cq) = 0; }; diff --git a/include/grpc++/impl/internal_stub.h b/include/grpc++/impl/internal_stub.h index 2cbf1d901b..370a3b8ac5 100644 --- a/include/grpc++/impl/internal_stub.h +++ b/include/grpc++/impl/internal_stub.h @@ -42,17 +42,14 @@ namespace grpc { class InternalStub { public: - InternalStub() {} + InternalStub(const std::shared_ptr<ChannelInterface>& channel) + : channel_(channel) {} virtual ~InternalStub() {} - void set_channel(const std::shared_ptr<ChannelInterface>& channel) { - channel_ = channel; - } - ChannelInterface* channel() { return channel_.get(); } private: - std::shared_ptr<ChannelInterface> channel_; + const std::shared_ptr<ChannelInterface> channel_; }; } // namespace grpc diff --git a/include/grpc++/impl/rpc_method.h b/include/grpc++/impl/rpc_method.h index e8909ac184..50a160b08c 100644 --- a/include/grpc++/impl/rpc_method.h +++ b/include/grpc++/impl/rpc_method.h @@ -45,17 +45,17 @@ class RpcMethod { BIDI_STREAMING }; - explicit RpcMethod(const char* name) - : name_(name), method_type_(NORMAL_RPC) {} - RpcMethod(const char* name, RpcType type) : name_(name), method_type_(type) {} + RpcMethod(const char* name, RpcType type, void* channel_tag) + : name_(name), method_type_(type), channel_tag_(channel_tag) {} const char* name() const { return name_; } - RpcType method_type() const { return method_type_; } + void* channel_tag() const { return channel_tag_; } private: - const char* name_; + const char* const name_; const RpcType method_type_; + void* const channel_tag_; }; } // namespace grpc diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 097667827a..50204d2099 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -167,7 +167,7 @@ class RpcServiceMethod : public RpcMethod { MethodHandler* handler, grpc::protobuf::Message* request_prototype, grpc::protobuf::Message* response_prototype) - : RpcMethod(name, type), + : RpcMethod(name, type, nullptr), handler_(handler), request_prototype_(request_prototype), response_prototype_(response_prototype) {} diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index e401da873b..ffab65ff59 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -361,7 +361,7 @@ typedef struct grpc_op { library). */ void grpc_init(void); -/* Shut down the grpc library. +/* Shut down the grpc library. No memory is used by grpc after this call returns, nor are any instructions executing within the grpc library. Prior to calling, all application owned grpc objects must have been @@ -395,9 +395,9 @@ void grpc_event_finish(grpc_event *event); /* Begin destruction of a completion queue. Once all possible events are drained then grpc_completion_queue_next will start to produce - GRPC_QUEUE_SHUTDOWN events only. At that point it's safe to call - grpc_completion_queue_destroy. - + GRPC_QUEUE_SHUTDOWN events only. At that point it's safe to call + grpc_completion_queue_destroy. + After calling this function applications should ensure that no NEW work is added to be published on this completion queue. */ void grpc_completion_queue_shutdown(grpc_completion_queue *cq); @@ -421,6 +421,15 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, const char *method, const char *host, gpr_timespec deadline); +/* Pre-register a method/host pair on a channel. */ +void *grpc_channel_register_call(grpc_channel *channel, const char *method, + const char *host); + +/* Create a call given a handle returned from grpc_channel_register_call */ +grpc_call *grpc_channel_create_registered_call( + grpc_channel *channel, grpc_completion_queue *completion_queue, + void *registered_call_handle, gpr_timespec deadline); + /* Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' to the completion queue bound to the call. The order of ops specified in the batch has no significance. @@ -579,8 +588,7 @@ grpc_call_error grpc_server_request_call_old(grpc_server *server, grpc_call_error grpc_server_request_call( grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, - grpc_completion_queue *cq_bound_to_call, - void *tag_new); + grpc_completion_queue *cq_bound_to_call, void *tag_new); /* Registers a method in the server. Methods to this (host, method) pair will not be reported by @@ -635,4 +643,4 @@ void grpc_server_destroy(grpc_server *server); } #endif -#endif /* GRPC_GRPC_H */ +#endif /* GRPC_GRPC_H */ |