aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-07-09 12:32:48 -0700
committerGravatar yang-g <yangg@google.com>2015-07-09 12:32:48 -0700
commit3315a845efaf2116cce6184b459f8bb4e642bdde (patch)
tree47ca40731d6f9ba689a060f1734738769ed4d35e /include/grpc++
parentf9e8e59b1c113b614736b89cb2cb4e543ba82d9f (diff)
parent494886a1be23865af7eb223b1a190fb9d2e2cc30 (diff)
Merge remote-tracking branch 'upstream/master' into security_context2
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/credentials.h6
-rw-r--r--include/grpc++/server.h4
-rw-r--r--include/grpc++/server_builder.h33
3 files changed, 38 insertions, 5 deletions
diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h
index 7a40cd199d..0eaaefcbca 100644
--- a/include/grpc++/credentials.h
+++ b/include/grpc++/credentials.h
@@ -120,6 +120,12 @@ std::shared_ptr<Credentials> JWTCredentials(const grpc::string& json_key,
std::shared_ptr<Credentials> RefreshTokenCredentials(
const grpc::string& json_refresh_token);
+// Builds access token credentials.
+// access_token is an oauth2 access token that was fetched using an out of band
+// mechanism.
+std::shared_ptr<Credentials> AccessTokenCredentials(
+ const grpc::string& access_token);
+
// Builds IAM credentials.
std::shared_ptr<Credentials> IAMCredentials(
const grpc::string& authorization_token,
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index 6a9e757e77..94ee0b6a4a 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -84,8 +84,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
int max_message_size);
// Register a service. This call does not take ownership of the service.
// The service must exist for the lifetime of the Server instance.
- bool RegisterService(RpcService* service);
- bool RegisterAsyncService(AsynchronousService* service);
+ bool RegisterService(const grpc::string *host, RpcService* service);
+ bool RegisterAsyncService(const grpc::string *host, AsynchronousService* service);
void RegisterAsyncGenericService(AsyncGenericService* service);
// Add a listening port. Can be called multiple times.
int AddListeningPort(const grpc::string& addr, ServerCredentials* creds);
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_;