diff options
Diffstat (limited to 'include/grpc++/server_builder.h')
-rw-r--r-- | include/grpc++/server_builder.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index ecee475e3e..44ee00eec9 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -58,17 +58,35 @@ class ServerBuilder { // Register a service. This call does not take ownership of the service. // The service must exist for the lifetime of the Server instance returned by // BuildAndStart(). + // Matches requests with any :authority void RegisterService(SynchronousService* service); - // Register an asynchronous service. New calls will be delevered to cq. + // Register an asynchronous service. // This call does not take ownership of the service or completion queue. // The service and completion queuemust exist for the lifetime of the Server // instance returned by BuildAndStart(). + // Matches requests with any :authority void RegisterAsyncService(AsynchronousService* service); // Register a generic service. + // Matches requests with any :authority void RegisterAsyncGenericService(AsyncGenericService* service); + // Register a service. This call does not take ownership of the service. + // The service must exist for the lifetime of the Server instance returned by + // BuildAndStart(). + // Only matches requests with :authority \a host + void RegisterService(const grpc::string& host, + SynchronousService* service); + + // Register an asynchronous service. + // This call does not take ownership of the service or completion queue. + // The service and completion queuemust exist for the lifetime of the Server + // instance returned by BuildAndStart(). + // Only matches requests with :authority \a host + void RegisterAsyncService(const grpc::string& host, + AsynchronousService* service); + // Set max message size in bytes. void SetMaxMessageSize(int max_message_size) { max_message_size_ = max_message_size; @@ -98,9 +116,18 @@ class ServerBuilder { int* selected_port; }; + typedef std::unique_ptr<grpc::string> HostString; + template <class T> struct NamedService { + explicit NamedService(T* s) : service(s) {} + NamedService(const grpc::string& h, T *s) + : host(new grpc::string(h)), service(s) {} + HostString host; + T* service; + }; + int max_message_size_; - std::vector<RpcService*> services_; - std::vector<AsynchronousService*> async_services_; + std::vector<std::unique_ptr<NamedService<RpcService>>> services_; + std::vector<std::unique_ptr<NamedService<AsynchronousService>>> async_services_; std::vector<Port> ports_; std::vector<ServerCompletionQueue*> cqs_; std::shared_ptr<ServerCredentials> creds_; |