aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-30 10:54:42 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-30 10:54:42 -0800
commit10f2790f7fedb7b54889c9ba8297a9e127edb143 (patch)
tree899151af9bc4ab60aac48ab67de4e84c1cd8062a /include
parentc354269ba7bd1f6dfe9c86ba18f38fc8e346dcfc (diff)
parent5f662537deb01539a204273977c7e32394fc3454 (diff)
Merge branch 'master' into execctx
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/impl/codegen/call.h5
-rw-r--r--include/grpc++/server_builder.h146
-rw-r--r--include/grpc/fork.h24
-rw-r--r--include/grpc/grpc_security.h2
-rw-r--r--include/grpc/impl/codegen/fork.h48
-rw-r--r--include/grpc/impl/codegen/grpc_types.h2
-rw-r--r--include/grpc/module.modulemap3
-rw-r--r--include/grpc/support/alloc.h2
-rw-r--r--include/grpc/support/log.h2
9 files changed, 162 insertions, 72 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index 41e95866cf..af2c2b510c 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -313,11 +313,6 @@ class CallOpSendMessage {
WriteOptions write_options_;
};
-namespace internal {
-template <class T>
-T Example();
-} // namespace internal
-
template <class M>
Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
write_options_ = options;
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 0888bef0d9..e2bae4b41f 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -55,13 +55,18 @@ class ServerBuilder {
ServerBuilder();
~ServerBuilder();
- /// Options for synchronous servers.
- enum SyncServerOption {
- NUM_CQS, ///< Number of completion queues.
- MIN_POLLERS, ///< Minimum number of polling threads.
- MAX_POLLERS, ///< Maximum number of polling threads.
- CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds.
- };
+ //////////////////////////////////////////////////////////////////////////////
+ // Primary API's
+
+ /// Return a running server which is ready for processing calls.
+ /// Before calling, one typically needs to ensure that:
+ /// 1. a service is registered - so that the server knows what to serve
+ /// (via RegisterService, or RegisterAsyncGenericService)
+ /// 2. a listening port has been added - so the server knows where to receive
+ /// traffic (via AddListeningPort)
+ /// 3. [for async api only] completion queues have been added via
+ /// AddCompletionQueue
+ std::unique_ptr<Server> BuildAndStart();
/// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the \a Server instance returned
@@ -69,9 +74,60 @@ class ServerBuilder {
/// Matches requests with any :authority
ServerBuilder& RegisterService(Service* service);
- /// Register a generic service.
- /// Matches requests with any :authority
- ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service);
+ /// Enlists an endpoint \a addr (port with an optional IP address) to
+ /// bind the \a grpc::Server object to be created to.
+ ///
+ /// It can be invoked multiple times.
+ ///
+ /// \param addr_uri The address to try to bind to the server in URI form. If
+ /// the scheme name is omitted, "dns:///" is assumed. To bind to any address,
+ /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4
+ /// connections. Valid values include dns:///localhost:1234, /
+ /// 192.168.1.1:31416, dns:///[::1]:27182, etc.).
+ /// \param creds The credentials associated with the server.
+ /// \param selected_port[out] If not `nullptr`, gets populated with the port
+ /// number bound to the \a grpc::Server for the corresponding endpoint after
+ /// it is successfully bound, 0 otherwise.
+ ///
+ ServerBuilder& AddListeningPort(const grpc::string& addr_uri,
+ std::shared_ptr<ServerCredentials> creds,
+ int* selected_port = nullptr);
+
+ /// Add a completion queue for handling asynchronous services.
+ ///
+ /// Best performance is typically obtained by using one thread per polling
+ /// completion queue.
+ ///
+ /// Caller is required to shutdown the server prior to shutting down the
+ /// returned completion queue. Caller is also required to drain the
+ /// completion queue after shutting it down. A typical usage scenario:
+ ///
+ /// // While building the server:
+ /// ServerBuilder builder;
+ /// ...
+ /// cq_ = builder.AddCompletionQueue();
+ /// server_ = builder.BuildAndStart();
+ ///
+ /// // While shutting down the server;
+ /// server_->Shutdown();
+ /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()!
+ /// // Drain the cq_ that was created
+ /// void* ignored_tag;
+ /// bool ignored_ok;
+ /// while (cq_->Next(&ignored_tag, &ignored_ok)) { }
+ ///
+ /// \param is_frequently_polled This is an optional parameter to inform gRPC
+ /// library about whether this completion queue would be frequently polled
+ /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is
+ /// 'true' and is the recommended setting. Setting this to 'false' (i.e.
+ /// not polling the completion queue frequently) will have a significantly
+ /// negative performance impact and hence should not be used in production
+ /// use cases.
+ std::unique_ptr<ServerCompletionQueue> AddCompletionQueue(
+ bool is_frequently_polled = true);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Less commonly used RegisterService variants
/// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the \a Server instance returned
@@ -79,6 +135,15 @@ class ServerBuilder {
/// Only matches requests with :authority \a host
ServerBuilder& RegisterService(const grpc::string& host, Service* service);
+ /// Register a generic service.
+ /// Matches requests with any :authority
+ /// This is mostly useful for writing generic gRPC Proxies where the exact
+ /// serialization format is unknown
+ ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Fine control knobs
+
/// Set max receive message size in bytes.
ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) {
max_receive_message_size_ = max_receive_message_size;
@@ -119,6 +184,14 @@ class ServerBuilder {
ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option);
+ /// Options for synchronous servers.
+ enum SyncServerOption {
+ NUM_CQS, ///< Number of completion queues.
+ MIN_POLLERS, ///< Minimum number of polling threads.
+ MAX_POLLERS, ///< Maximum number of polling threads.
+ CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds.
+ };
+
/// Only useful if this is a Synchronous server.
ServerBuilder& SetSyncServerOption(SyncServerOption option, int value);
@@ -129,59 +202,6 @@ class ServerBuilder {
return SetOption(MakeChannelArgumentOption(arg, value));
}
- /// Enlists an endpoint \a addr (port with an optional IP address) to
- /// bind the \a grpc::Server object to be created to.
- ///
- /// It can be invoked multiple times.
- ///
- /// \param addr_uri The address to try to bind to the server in URI form. If
- /// the scheme name is omitted, "dns:///" is assumed. To bind to any address,
- /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4
- /// connections. Valid values include dns:///localhost:1234, /
- /// 192.168.1.1:31416, dns:///[::1]:27182, etc.).
- /// \param creds The credentials associated with the server.
- /// \param selected_port[out] If not `nullptr`, gets populated with the port
- /// number bound to the \a grpc::Server for the corresponding endpoint after
- /// it is successfully bound, 0 otherwise.
- ///
- // TODO(dgq): the "port" part seems to be a misnomer.
- ServerBuilder& AddListeningPort(const grpc::string& addr_uri,
- std::shared_ptr<ServerCredentials> creds,
- int* selected_port = nullptr);
-
- /// Add a completion queue for handling asynchronous services.
- ///
- /// Caller is required to shutdown the server prior to shutting down the
- /// returned completion queue. Caller is also required to drain the
- /// completion queue after shutting it down. A typical usage scenario:
- ///
- /// // While building the server:
- /// ServerBuilder builder;
- /// ...
- /// cq_ = builder.AddCompletionQueue();
- /// server_ = builder.BuildAndStart();
- ///
- /// // While shutting down the server;
- /// server_->Shutdown();
- /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()!
- /// // Drain the cq_ that was created
- /// void* ignored_tag;
- /// bool ignored_ok;
- /// while (cq_->Next(&ignored_tag, &ignored_ok)) { }
- ///
- /// \param is_frequently_polled This is an optional parameter to inform gRPC
- /// library about whether this completion queue would be frequently polled
- /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is
- /// 'true' and is the recommended setting. Setting this to 'false' (i.e.
- /// not polling the completion queue frequently) will have a significantly
- /// negative performance impact and hence should not be used in production
- /// use cases.
- std::unique_ptr<ServerCompletionQueue> AddCompletionQueue(
- bool is_frequently_polled = true);
-
- /// Return a running server which is ready for processing calls.
- std::unique_ptr<Server> BuildAndStart();
-
/// For internal use only: Register a ServerBuilderPlugin factory function.
static void InternalAddPluginFactory(
std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)());
diff --git a/include/grpc/fork.h b/include/grpc/fork.h
new file mode 100644
index 0000000000..ca45e1139c
--- /dev/null
+++ b/include/grpc/fork.h
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_FORK_H
+#define GRPC_FORK_H
+
+#include <grpc/impl/codegen/fork.h>
+
+#endif /* GRPC_FORK_H */
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 7e87217de7..bae07ac309 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -185,7 +185,7 @@ GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create(
GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create(
void* reserved);
-GRPCAPI gpr_timespec grpc_max_auth_token_lifetime();
+GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(void);
/** Creates a JWT credentials object. May return NULL if the input is invalid.
- json_key is the JSON key string containing the client's private key.
diff --git a/include/grpc/impl/codegen/fork.h b/include/grpc/impl/codegen/fork.h
new file mode 100644
index 0000000000..baec7a2f10
--- /dev/null
+++ b/include/grpc/impl/codegen/fork.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_IMPL_CODEGEN_FORK_H
+#define GRPC_IMPL_CODEGEN_FORK_H
+
+/**
+ * gRPC applications should call this before calling fork(). There should be no
+ * active gRPC function calls between calling grpc_prefork() and
+ * grpc_postfork_parent()/grpc_postfork_child().
+ *
+ *
+ * Typical use:
+ * grpc_prefork();
+ * int pid = fork();
+ * if (pid) {
+ * grpc_postfork_parent();
+ * // Parent process..
+ * } else {
+ * grpc_postfork_child();
+ * // Child process...
+ * }
+ */
+
+void grpc_prefork();
+
+void grpc_postfork_parent();
+
+void grpc_postfork_child();
+
+void grpc_fork_handlers_auto_register();
+
+#endif /* GRPC_IMPL_CODEGEN_FORK_H */
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index 957286d27f..9ab2fc8b73 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -560,7 +560,7 @@ typedef struct grpc_op {
grpc_slice* status_details;
/** If this is not nullptr, it will be populated with the full fidelity
* error string for debugging purposes. The application is responsible
- * for freeing the data. */
+ * for freeing the data by using gpr_free(). */
const char** error_string;
} recv_status_on_client;
struct grpc_op_recv_close_on_server {
diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap
index 342adc0dc9..0faa448b70 100644
--- a/include/grpc/module.modulemap
+++ b/include/grpc/module.modulemap
@@ -21,6 +21,7 @@ framework module grpc {
header "support/tls.h"
header "support/useful.h"
header "impl/codegen/atm.h"
+ header "impl/codegen/fork.h"
header "impl/codegen/gpr_slice.h"
header "impl/codegen/gpr_types.h"
header "impl/codegen/port_platform.h"
@@ -36,6 +37,7 @@ framework module grpc {
header "impl/codegen/slice.h"
header "impl/codegen/status.h"
header "impl/codegen/atm.h"
+ header "impl/codegen/fork.h"
header "impl/codegen/gpr_slice.h"
header "impl/codegen/gpr_types.h"
header "impl/codegen/port_platform.h"
@@ -45,6 +47,7 @@ framework module grpc {
header "byte_buffer.h"
header "byte_buffer_reader.h"
header "compression.h"
+ header "fork.h"
header "grpc.h"
header "grpc_posix.h"
header "grpc_security_constants.h"
diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h
index 31cb225638..c559198237 100644
--- a/include/grpc/support/alloc.h
+++ b/include/grpc/support/alloc.h
@@ -58,7 +58,7 @@ GPRAPI void gpr_free_aligned(void* ptr);
GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions);
/** Return the family of allocation functions currently in effect. */
-GPRAPI gpr_allocation_functions gpr_get_allocation_functions();
+GPRAPI gpr_allocation_functions gpr_get_allocation_functions(void);
#ifdef __cplusplus
}
diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h
index 497cca9081..9cce4b1ae7 100644
--- a/include/grpc/support/log.h
+++ b/include/grpc/support/log.h
@@ -68,7 +68,7 @@ GPRAPI void gpr_log_message(const char* file, int line,
/** Set global log verbosity */
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
-GPRAPI void gpr_log_verbosity_init();
+GPRAPI void gpr_log_verbosity_init(void);
/** Log overrides: applications can use this API to intercept logging calls
and use their own implementations */