aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Feso <gabor.fecher@gmail.com>2018-10-04 21:31:14 +0100
committerGravatar Feso <gabor.fecher@gmail.com>2018-10-04 21:31:14 +0100
commitd74162f83acae2121cb2e47d562c0b963e20aac5 (patch)
treee88f96f2a2e1acd1d1572b56083753168ff6b114 /src
parent44cecbb2f73d1aaf65fd67d2e413c891210f54f1 (diff)
parent23b5b1a5a9c7084c5b64d4998ee15af0f77bd589 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.cc1
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc2
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc8
-rw-r--r--src/core/lib/channel/handshaker_factory.cc5
-rw-r--r--src/core/lib/channel/handshaker_factory.h2
-rw-r--r--src/core/lib/channel/handshaker_registry.cc8
-rw-r--r--src/core/lib/channel/handshaker_registry.h1
-rw-r--r--src/core/lib/http/httpcli_security_connector.cc3
-rw-r--r--src/core/lib/security/security_connector/alts_security_connector.cc12
-rw-r--r--src/core/lib/security/security_connector/security_connector.cc7
-rw-r--r--src/core/lib/security/security_connector/security_connector.h5
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc10
-rw-r--r--src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc3
-rw-r--r--src/core/tsi/alts/handshaker/alts_tsi_handshaker.h5
-rw-r--r--src/cpp/client/channel_cc.cc10
-rw-r--r--src/cpp/client/create_channel.cc42
-rw-r--r--src/cpp/client/create_channel_internal.cc10
-rw-r--r--src/cpp/client/create_channel_internal.h8
-rw-r--r--src/cpp/client/create_channel_posix.cc28
-rw-r--r--src/cpp/client/cronet_credentials.cc19
-rw-r--r--src/cpp/client/insecure_credentials.cc11
-rw-r--r--src/cpp/client/secure_credentials.cc12
-rw-r--r--src/cpp/client/secure_credentials.h6
-rw-r--r--src/cpp/server/server_cc.cc16
-rw-r--r--src/csharp/experimental/README.md4
25 files changed, 202 insertions, 36 deletions
diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
index 7ce8da8c00..bfabc68c66 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
@@ -351,6 +351,7 @@ static grpc_handshaker* grpc_http_connect_handshaker_create() {
static void handshaker_factory_add_handshakers(
grpc_handshaker_factory* factory, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr,
grpc_http_connect_handshaker_create());
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
index 0ac84032fd..5229304fa4 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -160,7 +160,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
static void start_handshake_locked(chttp2_connector* c) {
c->handshake_mgr = grpc_handshake_manager_create();
grpc_handshakers_add(HANDSHAKER_CLIENT, c->args.channel_args,
- c->handshake_mgr);
+ c->args.interested_parties, c->handshake_mgr);
grpc_endpoint_add_to_pollset_set(c->endpoint, c->args.interested_parties);
grpc_handshake_manager_do_handshake(
c->handshake_mgr, c->args.interested_parties, c->endpoint,
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 3f8a26ae32..b95baa9191 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -67,6 +67,7 @@ typedef struct {
grpc_timer timer;
grpc_closure on_timeout;
grpc_closure on_receive_settings;
+ grpc_pollset_set* interested_parties;
} server_connection_state;
static void server_connection_state_unref(
@@ -76,6 +77,9 @@ static void server_connection_state_unref(
GRPC_CHTTP2_UNREF_TRANSPORT(connection_state->transport,
"receive settings timeout");
}
+ grpc_pollset_set_del_pollset(connection_state->interested_parties,
+ connection_state->accepting_pollset);
+ grpc_pollset_set_destroy(connection_state->interested_parties);
gpr_free(connection_state);
}
}
@@ -189,7 +193,11 @@ static void on_accept(void* arg, grpc_endpoint* tcp,
connection_state->accepting_pollset = accepting_pollset;
connection_state->acceptor = acceptor;
connection_state->handshake_mgr = handshake_mgr;
+ connection_state->interested_parties = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset(connection_state->interested_parties,
+ connection_state->accepting_pollset);
grpc_handshakers_add(HANDSHAKER_SERVER, state->args,
+ connection_state->interested_parties,
connection_state->handshake_mgr);
const grpc_arg* timeout_arg =
grpc_channel_args_find(state->args, GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS);
diff --git a/src/core/lib/channel/handshaker_factory.cc b/src/core/lib/channel/handshaker_factory.cc
index 4fd43635b6..8ade8fe4e2 100644
--- a/src/core/lib/channel/handshaker_factory.cc
+++ b/src/core/lib/channel/handshaker_factory.cc
@@ -24,11 +24,12 @@
void grpc_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
if (handshaker_factory != nullptr) {
GPR_ASSERT(handshaker_factory->vtable != nullptr);
- handshaker_factory->vtable->add_handshakers(handshaker_factory, args,
- handshake_mgr);
+ handshaker_factory->vtable->add_handshakers(
+ handshaker_factory, args, interested_parties, handshake_mgr);
}
}
diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h
index 3e45fcf20e..e17a678179 100644
--- a/src/core/lib/channel/handshaker_factory.h
+++ b/src/core/lib/channel/handshaker_factory.h
@@ -32,6 +32,7 @@ typedef struct grpc_handshaker_factory grpc_handshaker_factory;
typedef struct {
void (*add_handshakers)(grpc_handshaker_factory* handshaker_factory,
const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr);
void (*destroy)(grpc_handshaker_factory* handshaker_factory);
} grpc_handshaker_factory_vtable;
@@ -42,6 +43,7 @@ struct grpc_handshaker_factory {
void grpc_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr);
void grpc_handshaker_factory_destroy(
diff --git a/src/core/lib/channel/handshaker_registry.cc b/src/core/lib/channel/handshaker_registry.cc
index eec3e1b352..fbafc43e79 100644
--- a/src/core/lib/channel/handshaker_registry.cc
+++ b/src/core/lib/channel/handshaker_registry.cc
@@ -51,9 +51,11 @@ static void grpc_handshaker_factory_list_register(
static void grpc_handshaker_factory_list_add_handshakers(
grpc_handshaker_factory_list* list, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
for (size_t i = 0; i < list->num_factories; ++i) {
- grpc_handshaker_factory_add_handshakers(list->list[i], args, handshake_mgr);
+ grpc_handshaker_factory_add_handshakers(list->list[i], args,
+ interested_parties, handshake_mgr);
}
}
@@ -91,7 +93,9 @@ void grpc_handshaker_factory_register(bool at_start,
void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
grpc_handshaker_factory_list_add_handshakers(
- &g_handshaker_factory_lists[handshaker_type], args, handshake_mgr);
+ &g_handshaker_factory_lists[handshaker_type], args, interested_parties,
+ handshake_mgr);
}
diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h
index 82ad9c5b9a..3dd4316de6 100644
--- a/src/core/lib/channel/handshaker_registry.h
+++ b/src/core/lib/channel/handshaker_registry.h
@@ -43,6 +43,7 @@ void grpc_handshaker_factory_register(bool at_start,
void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr);
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */
diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc
index 50078c37a1..98fb7d3937 100644
--- a/src/core/lib/http/httpcli_security_connector.cc
+++ b/src/core/lib/http/httpcli_security_connector.cc
@@ -189,7 +189,8 @@ static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
grpc_channel_args args = {1, &channel_arg};
c->handshake_mgr = grpc_handshake_manager_create();
- grpc_handshakers_add(HANDSHAKER_CLIENT, &args, c->handshake_mgr);
+ grpc_handshakers_add(HANDSHAKER_CLIENT, &args,
+ nullptr /* interested_parties */, c->handshake_mgr);
grpc_handshake_manager_do_handshake(
c->handshake_mgr, nullptr /* interested_parties */, tcp,
nullptr /* channel_args */, deadline, nullptr /* acceptor */,
diff --git a/src/core/lib/security/security_connector/alts_security_connector.cc b/src/core/lib/security/security_connector/alts_security_connector.cc
index 35a787871a..f157c93171 100644
--- a/src/core/lib/security/security_connector/alts_security_connector.cc
+++ b/src/core/lib/security/security_connector/alts_security_connector.cc
@@ -70,9 +70,9 @@ static void alts_channel_add_handshakers(
auto c = reinterpret_cast<grpc_alts_channel_security_connector*>(sc);
grpc_alts_credentials* creds =
reinterpret_cast<grpc_alts_credentials*>(c->base.channel_creds);
- GPR_ASSERT(alts_tsi_handshaker_create(creds->options, c->target_name,
- creds->handshaker_service_url, true,
- &handshaker) == TSI_OK);
+ GPR_ASSERT(alts_tsi_handshaker_create(
+ creds->options, c->target_name, creds->handshaker_service_url,
+ true, sc->base.interested_parties, &handshaker) == TSI_OK);
grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create(
handshaker, &sc->base));
}
@@ -84,9 +84,9 @@ static void alts_server_add_handshakers(
auto c = reinterpret_cast<grpc_alts_server_security_connector*>(sc);
grpc_alts_server_credentials* creds =
reinterpret_cast<grpc_alts_server_credentials*>(c->base.server_creds);
- GPR_ASSERT(alts_tsi_handshaker_create(creds->options, nullptr,
- creds->handshaker_service_url, false,
- &handshaker) == TSI_OK);
+ GPR_ASSERT(alts_tsi_handshaker_create(
+ creds->options, nullptr, creds->handshaker_service_url, false,
+ sc->base.interested_parties, &handshaker) == TSI_OK);
grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create(
handshaker, &sc->base));
}
diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc
index 6246613e7b..f4490582a3 100644
--- a/src/core/lib/security/security_connector/security_connector.cc
+++ b/src/core/lib/security/security_connector/security_connector.cc
@@ -156,6 +156,13 @@ int grpc_security_connector_cmp(grpc_security_connector* sc,
return sc->vtable->cmp(sc, other);
}
+void grpc_security_connector_set_interested_parties(
+ grpc_security_connector* sc, grpc_pollset_set* interested_parties) {
+ if (sc != nullptr) {
+ sc->interested_parties = interested_parties;
+ }
+}
+
int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
grpc_channel_security_connector* sc2) {
GPR_ASSERT(sc1->channel_creds != nullptr);
diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h
index 67a506b576..f0172594ad 100644
--- a/src/core/lib/security/security_connector/security_connector.h
+++ b/src/core/lib/security/security_connector/security_connector.h
@@ -63,6 +63,7 @@ struct grpc_security_connector {
const grpc_security_connector_vtable* vtable;
gpr_refcount refcount;
const char* url_scheme;
+ grpc_pollset_set* interested_parties;
};
/* Refcounting. */
@@ -106,6 +107,10 @@ grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg);
grpc_security_connector* grpc_security_connector_find_in_args(
const grpc_channel_args* args);
+/* Util to set the interested_parties whose ownership is not transferred. */
+void grpc_security_connector_set_interested_parties(
+ grpc_security_connector* sc, grpc_pollset_set* interested_parties);
+
/* --- channel_security_connector object. ---
A channel security connector object represents a way to configure the
diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc
index d76d582638..f3bdf573b3 100644
--- a/src/core/lib/security/transport/security_handshaker.cc
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -475,20 +475,30 @@ static grpc_handshaker* fail_handshaker_create() {
static void client_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
grpc_channel_security_connector* security_connector =
reinterpret_cast<grpc_channel_security_connector*>(
grpc_security_connector_find_in_args(args));
+ if (security_connector != nullptr) {
+ grpc_security_connector_set_interested_parties(&security_connector->base,
+ interested_parties);
+ }
grpc_channel_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void server_handshaker_factory_add_handshakers(
grpc_handshaker_factory* hf, const grpc_channel_args* args,
+ grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) {
grpc_server_security_connector* security_connector =
reinterpret_cast<grpc_server_security_connector*>(
grpc_security_connector_find_in_args(args));
+ if (security_connector != nullptr) {
+ grpc_security_connector_set_interested_parties(&security_connector->base,
+ interested_parties);
+ }
grpc_server_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
index 34608a3de1..dfdd659b87 100644
--- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
+++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
@@ -347,7 +347,8 @@ static void init_shared_resources(const char* handshaker_service_url) {
tsi_result alts_tsi_handshaker_create(
const grpc_alts_credentials_options* options, const char* target_name,
- const char* handshaker_service_url, bool is_client, tsi_handshaker** self) {
+ const char* handshaker_service_url, bool is_client,
+ grpc_pollset_set* interested_parties, tsi_handshaker** self) {
if (handshaker_service_url == nullptr || self == nullptr ||
options == nullptr || (is_client && target_name == nullptr)) {
gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_handshaker_create()");
diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h
index 227b30ce53..48ce69b1da 100644
--- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h
+++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h
@@ -23,6 +23,7 @@
#include <grpc/grpc.h>
+#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
#include "src/core/tsi/alts_transport_security.h"
#include "src/core/tsi/transport_security.h"
@@ -51,6 +52,7 @@ typedef struct alts_tsi_handshaker alts_tsi_handshaker;
* "host:port".
* - is_client: boolean value indicating if the handshaker is used at the client
* (is_client = true) or server (is_client = false) side.
+ * - interested_parties: set of pollsets interested in this connection.
* - self: address of ALTS TSI handshaker instance to be returned from the
* method.
*
@@ -58,7 +60,8 @@ typedef struct alts_tsi_handshaker alts_tsi_handshaker;
*/
tsi_result alts_tsi_handshaker_create(
const grpc_alts_credentials_options* options, const char* target_name,
- const char* handshaker_service_url, bool is_client, tsi_handshaker** self);
+ const char* handshaker_service_url, bool is_client,
+ grpc_pollset_set* interested_parties, tsi_handshaker** self);
/**
* This method handles handshaker response returned from ALTS handshaker
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc
index 31c02893b1..2cab41b3f5 100644
--- a/src/cpp/client/channel_cc.cc
+++ b/src/cpp/client/channel_cc.cc
@@ -51,8 +51,16 @@
namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer;
-Channel::Channel(const grpc::string& host, grpc_channel* channel)
+Channel::Channel(
+ const grpc::string& host, grpc_channel* channel,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators)
: host_(host), c_channel_(channel) {
+ auto* vector = interceptor_creators.release();
+ if (vector != nullptr) {
+ interceptor_creators_ = std::move(*vector);
+ }
g_gli_initializer.summon();
}
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index 67a46ce0e1..efdff6c265 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -39,11 +39,43 @@ std::shared_ptr<Channel> CreateCustomChannel(
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds.
- return creds ? creds->CreateChannel(target, args)
- : CreateChannelInternal(
- "", grpc_lame_client_channel_create(
- nullptr, GRPC_STATUS_INVALID_ARGUMENT,
- "Invalid credentials."));
+ return creds
+ ? creds->CreateChannel(target, args)
+ : CreateChannelInternal("",
+ grpc_lame_client_channel_create(
+ nullptr, GRPC_STATUS_INVALID_ARGUMENT,
+ "Invalid credentials."),
+ nullptr);
}
+namespace experimental {
+/// Create a new \em custom \a Channel pointing to \a target with \a
+/// interceptors being invoked per call.
+///
+/// \warning For advanced use and testing ONLY. Override default channel
+/// arguments only if necessary.
+///
+/// \param target The URI of the endpoint to connect to.
+/// \param creds Credentials to use for the created channel. If it does not
+/// hold an object or is invalid, a lame channel (one on which all operations
+/// fail) is returned.
+/// \param args Options for channel creation.
+std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
+ const grpc::string& target,
+ const std::shared_ptr<ChannelCredentials>& creds,
+ const ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) {
+ return creds
+ ? creds->CreateChannelWithInterceptors(
+ target, args, std::move(interceptor_creators))
+ : CreateChannelInternal("",
+ grpc_lame_client_channel_create(
+ nullptr, GRPC_STATUS_INVALID_ARGUMENT,
+ "Invalid credentials."),
+ nullptr);
+}
+} // namespace experimental
+
} // namespace grpc
diff --git a/src/cpp/client/create_channel_internal.cc b/src/cpp/client/create_channel_internal.cc
index aa96edfcff..313d682aae 100644
--- a/src/cpp/client/create_channel_internal.cc
+++ b/src/cpp/client/create_channel_internal.cc
@@ -24,8 +24,12 @@ struct grpc_channel;
namespace grpc {
-std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host,
- grpc_channel* c_channel) {
- return std::shared_ptr<Channel>(new Channel(host, c_channel));
+std::shared_ptr<Channel> CreateChannelInternal(
+ const grpc::string& host, grpc_channel* c_channel,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) {
+ return std::shared_ptr<Channel>(
+ new Channel(host, c_channel, std::move(interceptor_creators)));
}
} // namespace grpc
diff --git a/src/cpp/client/create_channel_internal.h b/src/cpp/client/create_channel_internal.h
index 86e8167277..512fc22866 100644
--- a/src/cpp/client/create_channel_internal.h
+++ b/src/cpp/client/create_channel_internal.h
@@ -21,6 +21,7 @@
#include <memory>
+#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/support/config.h>
struct grpc_channel;
@@ -28,8 +29,11 @@ struct grpc_channel;
namespace grpc {
class Channel;
-std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host,
- grpc_channel* c_channel);
+std::shared_ptr<Channel> CreateChannelInternal(
+ const grpc::string& host, grpc_channel* c_channel,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators);
} // namespace grpc
diff --git a/src/cpp/client/create_channel_posix.cc b/src/cpp/client/create_channel_posix.cc
index f9285c9b28..8d775e7a87 100644
--- a/src/cpp/client/create_channel_posix.cc
+++ b/src/cpp/client/create_channel_posix.cc
@@ -33,7 +33,8 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
internal::GrpcLibrary init_lib;
init_lib.init();
return CreateChannelInternal(
- "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr));
+ "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr),
+ nullptr);
}
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
@@ -42,10 +43,31 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
- return CreateChannelInternal("", grpc_insecure_channel_create_from_fd(
- target.c_str(), fd, &channel_args));
+ return CreateChannelInternal(
+ "",
+ grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
+ nullptr);
+}
+
+namespace experimental {
+
+std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
+ const grpc::string& target, int fd, const ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) {
+ internal::GrpcLibrary init_lib;
+ init_lib.init();
+ grpc_channel_args channel_args;
+ args.SetChannelArgs(&channel_args);
+ return CreateChannelInternal(
+ "",
+ grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
+ std::move(interceptor_creators));
}
+} // namespace experimental
+
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc
diff --git a/src/cpp/client/cronet_credentials.cc b/src/cpp/client/cronet_credentials.cc
index 5c65ad05ea..09a76b428c 100644
--- a/src/cpp/client/cronet_credentials.cc
+++ b/src/cpp/client/cronet_credentials.cc
@@ -31,16 +31,25 @@ class CronetChannelCredentialsImpl final : public ChannelCredentials {
std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override {
- grpc_channel_args channel_args;
- args.SetChannelArgs(&channel_args);
- return CreateChannelInternal(
- "", grpc_cronet_secure_channel_create(engine_, target.c_str(),
- &channel_args, nullptr));
+ return CreateChannelWithInterceptors(target, args, nullptr);
}
SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
private:
+ std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
+ const string& target, const grpc::ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) override {
+ grpc_channel_args channel_args;
+ args.SetChannelArgs(&channel_args);
+ return CreateChannelInternal(
+ "",
+ grpc_cronet_secure_channel_create(engine_, target.c_str(),
+ &channel_args, nullptr),
+ std::move(interceptor_creators));
+ }
void* engine_;
};
diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc
index 04dc5c0bcc..b816e0c59a 100644
--- a/src/cpp/client/insecure_credentials.cc
+++ b/src/cpp/client/insecure_credentials.cc
@@ -32,11 +32,20 @@ class InsecureChannelCredentialsImpl final : public ChannelCredentials {
public:
std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override {
+ return CreateChannelWithInterceptors(target, args, nullptr);
+ }
+
+ std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
+ const string& target, const grpc::ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) override {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
"",
- grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr));
+ grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr),
+ std::move(interceptor_creators));
}
SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index e48fbeb86d..d1cd78e755 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -36,12 +36,22 @@ SecureChannelCredentials::SecureChannelCredentials(
std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel(
const string& target, const grpc::ChannelArguments& args) {
+ return CreateChannelWithInterceptors(target, args, nullptr);
+}
+
+std::shared_ptr<grpc::Channel>
+SecureChannelCredentials::CreateChannelWithInterceptors(
+ const string& target, const grpc::ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
args.GetSslTargetNameOverride(),
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args,
- nullptr));
+ nullptr),
+ std::move(interceptor_creators));
}
SecureCallCredentials::SecureCallCredentials(grpc_call_credentials* c_creds)
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index 85cb54227c..bfb6e17ee9 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -36,9 +36,15 @@ class SecureChannelCredentials final : public ChannelCredentials {
std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override;
+
SecureChannelCredentials* AsSecureCredentials() override { return this; }
private:
+ std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
+ const string& target, const grpc::ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) override;
grpc_channel_credentials* const c_creds_;
};
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 36f7eb81f9..7c764f4bce 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -473,7 +473,21 @@ std::shared_ptr<Channel> Server::InProcessChannel(
const ChannelArguments& args) {
grpc_channel_args channel_args = args.c_channel_args();
return CreateChannelInternal(
- "inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr));
+ "inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr),
+ nullptr);
+}
+
+std::shared_ptr<Channel>
+Server::experimental_type::InProcessChannelWithInterceptors(
+ const ChannelArguments& args,
+ std::unique_ptr<std::vector<
+ std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
+ interceptor_creators) {
+ grpc_channel_args channel_args = args.c_channel_args();
+ return CreateChannelInternal(
+ "inproc",
+ grpc_inproc_channel_create(server_->server_, &channel_args, nullptr),
+ std::move(interceptor_creators));
}
static grpc_server_register_method_payload_handling PayloadHandlingForMethod(
diff --git a/src/csharp/experimental/README.md b/src/csharp/experimental/README.md
index bd53cbcd35..64515075ce 100644
--- a/src/csharp/experimental/README.md
+++ b/src/csharp/experimental/README.md
@@ -22,10 +22,14 @@ gRPC C# now has experimental support for Unity. Please try using gRPC with
Unity and provide feedback!
How to test gRPC in a Unity project
+
1. Create a Unity project that targets .NET 4.x (Edit -> Project Settings -> Editor -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement.
+
2. Download the latest development build of `grpc_unity_package.VERSION.zip` from
[daily builds](https://packages.grpc.io/)
+
3. Extract the `.zip` file in the `Assets` directory in your Unity project
+
4. Unity IDE will pick up all the bundled files and add them to project automatically.
You should be able to use gRPC and Protobuf in your scripts from now on.