diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/client_context.h | 14 | ||||
-rw-r--r-- | include/grpc++/create_channel.h | 2 | ||||
-rw-r--r-- | include/grpc++/credentials.h | 35 | ||||
-rw-r--r-- | include/grpc/grpc_http.h | 67 | ||||
-rw-r--r-- | include/grpc/support/subprocess.h | 2 |
5 files changed, 29 insertions, 91 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index a58e9872e6..6d9015f278 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -51,6 +51,7 @@ namespace grpc { class CallOpBuffer; class ChannelInterface; class CompletionQueue; +class Credentials; class RpcMethod; class Status; template <class R> @@ -102,6 +103,11 @@ class ClientContext { void set_authority(const grpc::string& authority) { authority_ = authority; } + // Set credentials for the rpc. + void set_credentials(const std::shared_ptr<Credentials>& creds) { + creds_ = creds; + } + void TryCancel(); private: @@ -127,11 +133,8 @@ class ClientContext { friend class ::grpc::ClientAsyncResponseReader; grpc_call* call() { return call_; } - void set_call(grpc_call* call, const std::shared_ptr<ChannelInterface>& channel) { - GPR_ASSERT(call_ == nullptr); - call_ = call; - channel_ = channel; - } + void set_call(grpc_call* call, + const std::shared_ptr<ChannelInterface>& channel); grpc_completion_queue* cq() { return cq_; } void set_cq(grpc_completion_queue* cq) { cq_ = cq; } @@ -144,6 +147,7 @@ class ClientContext { grpc_completion_queue* cq_; gpr_timespec deadline_; grpc::string authority_; + std::shared_ptr<Credentials> creds_; std::multimap<grpc::string, grpc::string> send_initial_metadata_; std::multimap<grpc::string, grpc::string> recv_initial_metadata_; std::multimap<grpc::string, grpc::string> trailing_metadata_; diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index da375b97db..424a93a64c 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -45,7 +45,7 @@ class ChannelInterface; // If creds does not hold an object or is invalid, a lame channel is returned. std::shared_ptr<ChannelInterface> CreateChannel( - const grpc::string& target, const std::unique_ptr<Credentials>& creds, + const grpc::string& target, const std::shared_ptr<Credentials>& creds, const ChannelArguments& args); } // namespace grpc diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index 61c4094691..7a40cd199d 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -47,17 +47,18 @@ class SecureCredentials; class Credentials : public GrpcLibrary { public: ~Credentials() GRPC_OVERRIDE; + virtual bool ApplyToCall(grpc_call* call) = 0; protected: - friend std::unique_ptr<Credentials> CompositeCredentials( - const std::unique_ptr<Credentials>& creds1, - const std::unique_ptr<Credentials>& creds2); + friend std::shared_ptr<Credentials> CompositeCredentials( + const std::shared_ptr<Credentials>& creds1, + const std::shared_ptr<Credentials>& creds2); virtual SecureCredentials* AsSecureCredentials() = 0; private: friend std::shared_ptr<ChannelInterface> CreateChannel( - const grpc::string& target, const std::unique_ptr<Credentials>& creds, + const grpc::string& target, const std::shared_ptr<Credentials>& creds, const ChannelArguments& args); virtual std::shared_ptr<ChannelInterface> CreateChannel( @@ -80,20 +81,20 @@ struct SslCredentialsOptions { }; // Factories for building different types of Credentials -// The functions may return empty unique_ptr when credentials cannot be created. +// The functions may return empty shared_ptr when credentials cannot be created. // If a Credentials pointer is returned, it can still be invalid when used to // create a channel. A lame channel will be created then and all rpcs will // fail on it. // Builds credentials with reasonable defaults. -std::unique_ptr<Credentials> GoogleDefaultCredentials(); +std::shared_ptr<Credentials> GoogleDefaultCredentials(); // Builds SSL Credentials given SSL specific options -std::unique_ptr<Credentials> SslCredentials( +std::shared_ptr<Credentials> SslCredentials( const SslCredentialsOptions& options); // Builds credentials for use when running in GCE -std::unique_ptr<Credentials> ComputeEngineCredentials(); +std::shared_ptr<Credentials> ComputeEngineCredentials(); // Builds service account credentials. // json_key is the JSON key string containing the client's private key. @@ -101,7 +102,7 @@ std::unique_ptr<Credentials> ComputeEngineCredentials(); // token_lifetime_seconds is the lifetime in seconds of each token acquired // through this service account credentials. It should be positive and should // not exceed grpc_max_auth_token_lifetime or will be cropped to this value. -std::unique_ptr<Credentials> ServiceAccountCredentials( +std::shared_ptr<Credentials> ServiceAccountCredentials( const grpc::string& json_key, const grpc::string& scope, long token_lifetime_seconds); @@ -110,27 +111,27 @@ std::unique_ptr<Credentials> ServiceAccountCredentials( // token_lifetime_seconds is the lifetime in seconds of each Json Web Token // (JWT) created with this credentials. It should not exceed // grpc_max_auth_token_lifetime or will be cropped to this value. -std::unique_ptr<Credentials> JWTCredentials( - const grpc::string& json_key, long token_lifetime_seconds); +std::shared_ptr<Credentials> JWTCredentials(const grpc::string& json_key, + long token_lifetime_seconds); // Builds refresh token credentials. // json_refresh_token is the JSON string containing the refresh token along // with a client_id and client_secret. -std::unique_ptr<Credentials> RefreshTokenCredentials( +std::shared_ptr<Credentials> RefreshTokenCredentials( const grpc::string& json_refresh_token); // Builds IAM credentials. -std::unique_ptr<Credentials> IAMCredentials( +std::shared_ptr<Credentials> IAMCredentials( const grpc::string& authorization_token, const grpc::string& authority_selector); // Combines two credentials objects into a composite credentials -std::unique_ptr<Credentials> CompositeCredentials( - const std::unique_ptr<Credentials>& creds1, - const std::unique_ptr<Credentials>& creds2); +std::shared_ptr<Credentials> CompositeCredentials( + const std::shared_ptr<Credentials>& creds1, + const std::shared_ptr<Credentials>& creds2); // Credentials for an unencrypted, unauthenticated channel -std::unique_ptr<Credentials> InsecureCredentials(); +std::shared_ptr<Credentials> InsecureCredentials(); } // namespace grpc diff --git a/include/grpc/grpc_http.h b/include/grpc/grpc_http.h deleted file mode 100644 index c41e87413f..0000000000 --- a/include/grpc/grpc_http.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_GRPC_HTTP_H -#define GRPC_GRPC_HTTP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* HTTP GET support. - - HTTP2 servers can publish statically generated text content served - via HTTP2 GET queries by publishing one or more grpc_http_server_page - elements via repeated GRPC_ARG_SERVE_OVER_HTTP elements in the servers - channel_args. - - This is not: - - a general purpose web server - - particularly fast - - It's useful for being able to serve up some static content (maybe some - javascript to be able to interact with your GRPC server?) */ - -typedef struct { - const char *path; - const char *content_type; - const char *content; -} grpc_http_server_page; - -#define GRPC_ARG_SERVE_OVER_HTTP "grpc.serve_over_http" - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_GRPC_HTTP_H */ diff --git a/include/grpc/support/subprocess.h b/include/grpc/support/subprocess.h index c59751da83..1b7431e7d9 100644 --- a/include/grpc/support/subprocess.h +++ b/include/grpc/support/subprocess.h @@ -37,7 +37,7 @@ typedef struct gpr_subprocess gpr_subprocess; /* .exe on windows, empty on unices */ -char *gpr_subprocess_binary_extension(); +const char *gpr_subprocess_binary_extension(); gpr_subprocess *gpr_subprocess_create(int argc, char **argv); /* if subprocess has not been joined, kill it */ |