aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-06-04 08:43:47 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-06-04 08:43:47 -0700
commit7b6e979f46174ffe1893bea868b3cd9f18c25639 (patch)
tree5bb1f5609186f406a1c36dec77815fe31ef3b9a7 /src
parenta4b89fed1c801cdb31a154c7e1c09e5650898e8a (diff)
parentbed8a0699e7440ab13cddda03a398bad26117f5b (diff)
Merge github.com:grpc/grpc into you-complete-me
Diffstat (limited to 'src')
-rw-r--r--src/core/channel/channel_args.c1
-rw-r--r--src/core/httpcli/format_request.c1
-rw-r--r--src/core/httpcli/httpcli.c1
-rw-r--r--src/core/httpcli/httpcli_security_connector.c1
-rw-r--r--src/core/iomgr/endpoint_pair_posix.c1
-rw-r--r--src/core/iomgr/iomgr.c3
-rw-r--r--src/core/iomgr/resolve_address_posix.c1
-rw-r--r--src/core/iomgr/resolve_address_windows.c1
-rw-r--r--src/core/iomgr/sockaddr_utils.c1
-rw-r--r--src/core/iomgr/tcp_client_posix.c1
-rw-r--r--src/core/iomgr/tcp_server_posix.c1
-rw-r--r--src/core/iomgr/tcp_server_windows.c1
-rw-r--r--src/core/iomgr/tcp_windows.c1
-rw-r--r--src/core/security/client_auth_filter.c1
-rw-r--r--src/core/security/credentials.c1
-rw-r--r--src/core/security/credentials_posix.c1
-rw-r--r--src/core/security/credentials_win32.c1
-rw-r--r--src/core/security/json_token.c1
-rw-r--r--src/core/security/security_connector.c1
-rw-r--r--src/core/security/security_context.c1
-rw-r--r--src/core/security/server_auth_filter.c1
-rw-r--r--src/core/support/cmdline.c1
-rw-r--r--src/core/support/env_linux.c1
-rw-r--r--src/core/support/env_posix.c1
-rw-r--r--src/core/support/env_win32.c1
-rw-r--r--src/core/support/file.c1
-rw-r--r--src/core/support/file_posix.c1
-rw-r--r--src/core/support/file_win32.c1
-rw-r--r--src/core/support/host_port.c1
-rw-r--r--src/core/support/string.h14
-rw-r--r--src/core/surface/byte_buffer_reader.c15
-rw-r--r--src/core/surface/call.c1
-rw-r--r--src/core/surface/call_log_batch.c1
-rw-r--r--src/core/surface/channel_create.c1
-rw-r--r--src/core/surface/event_string.c1
-rw-r--r--src/core/surface/secure_channel_create.c1
-rw-r--r--src/core/surface/server.c1
-rw-r--r--src/core/transport/transport_op_string.c1
-rw-r--r--src/cpp/proto/proto_utils.cc11
-rw-r--r--src/cpp/server/create_default_thread_pool.cc49
-rw-r--r--src/cpp/server/server_builder.cc4
-rw-r--r--src/cpp/server/thread_pool.h2
-rw-r--r--src/cpp/util/byte_buffer.cc7
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c9
-rw-r--r--src/node/README.md26
-rw-r--r--src/node/cli/service_packager.js2
-rw-r--r--src/node/examples/perf_test.js2
-rw-r--r--src/node/examples/route_guide_client.js2
-rw-r--r--src/node/examples/route_guide_server.js2
-rw-r--r--src/node/examples/stock_server.js2
-rw-r--r--src/node/ext/byte_buffer.cc6
-rw-r--r--src/node/index.js2
-rw-r--r--src/node/interop/interop_client.js2
-rw-r--r--src/node/interop/interop_server.js2
-rw-r--r--src/node/package.json5
-rw-r--r--src/node/src/client.js2
-rw-r--r--src/node/src/common.js11
-rw-r--r--src/node/src/server.js4
-rw-r--r--src/node/test/surface_test.js6
-rw-r--r--src/objective-c/GRPCClient/private/NSData+GRPC.m13
-rw-r--r--src/php/ext/grpc/byte_buffer.c6
-rw-r--r--src/python/README.md63
-rw-r--r--src/python/src/grpc/_adapter/_c/utility.c22
-rw-r--r--src/python/src/grpc/_adapter/_links_test.py2
-rw-r--r--src/ruby/README.md80
-rw-r--r--src/ruby/ext/grpc/rb_byte_buffer.c7
-rw-r--r--src/ruby/lib/grpc/version.rb2
67 files changed, 244 insertions, 176 deletions
diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c
index 509ae0df89..1b0e33b123 100644
--- a/src/core/channel/channel_args.c
+++ b/src/core/channel/channel_args.c
@@ -36,6 +36,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
#include <string.h>
diff --git a/src/core/httpcli/format_request.c b/src/core/httpcli/format_request.c
index af25219084..e875423e87 100644
--- a/src/core/httpcli/format_request.c
+++ b/src/core/httpcli/format_request.c
@@ -40,6 +40,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
static void fill_common_header(const grpc_httpcli_request *request, gpr_strvec *buf) {
diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c
index 6e4156c385..fa7aabc418 100644
--- a/src/core/httpcli/httpcli.c
+++ b/src/core/httpcli/httpcli.c
@@ -46,6 +46,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
typedef struct {
gpr_slice request_text;
diff --git a/src/core/httpcli/httpcli_security_connector.c b/src/core/httpcli/httpcli_security_connector.c
index 6eed5eaf12..ce0d3d5a70 100644
--- a/src/core/httpcli/httpcli_security_connector.c
+++ b/src/core/httpcli/httpcli_security_connector.c
@@ -39,6 +39,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/tsi/ssl_transport_security.h"
typedef struct {
diff --git a/src/core/iomgr/endpoint_pair_posix.c b/src/core/iomgr/endpoint_pair_posix.c
index 9b3b63f1e7..fa2d2555d6 100644
--- a/src/core/iomgr/endpoint_pair_posix.c
+++ b/src/core/iomgr/endpoint_pair_posix.c
@@ -47,6 +47,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
static void create_sockets(int sv[2]) {
int flags;
diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c
index 249228a214..fa8dcc5b4a 100644
--- a/src/core/iomgr/iomgr.c
+++ b/src/core/iomgr/iomgr.c
@@ -40,8 +40,9 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/thd.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
static gpr_mu g_mu;
static gpr_cv g_rcv;
diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c
index fcf48fe0d7..20d8c58eb4 100644
--- a/src/core/iomgr/resolve_address_posix.c
+++ b/src/core/iomgr/resolve_address_posix.c
@@ -47,6 +47,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
diff --git a/src/core/iomgr/resolve_address_windows.c b/src/core/iomgr/resolve_address_windows.c
index 7d0d2f9e7a..d388b04837 100644
--- a/src/core/iomgr/resolve_address_windows.c
+++ b/src/core/iomgr/resolve_address_windows.c
@@ -46,6 +46,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 3d202a5cc8..e91b94f8c8 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -40,6 +40,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
+#include <grpc/support/string_util.h>
static const gpr_uint8 kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xff};
diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c
index aa21ba9b9e..668a651947 100644
--- a/src/core/iomgr/tcp_client_posix.c
+++ b/src/core/iomgr/tcp_client_posix.c
@@ -51,6 +51,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
typedef struct {
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index 3cd40faafc..c49f3e1518 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -63,6 +63,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c
index 9ef369dfd8..d70968de88 100644
--- a/src/core/iomgr/tcp_server_windows.c
+++ b/src/core/iomgr/tcp_server_windows.c
@@ -41,6 +41,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_win32.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c
index 3341f558a3..12dac03080 100644
--- a/src/core/iomgr/tcp_windows.c
+++ b/src/core/iomgr/tcp_windows.c
@@ -41,6 +41,7 @@
#include <grpc/support/log.h>
#include <grpc/support/log_win32.h>
#include <grpc/support/slice_buffer.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include "src/core/iomgr/alarm.h"
diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c
index b2bce1fd32..0867bd7053 100644
--- a/src/core/security/client_auth_filter.c
+++ b/src/core/security/client_auth_filter.c
@@ -37,6 +37,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/string.h"
#include "src/core/channel/channel_stack.h"
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index 9bf5c32e74..f1ae6cecbc 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -46,6 +46,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
diff --git a/src/core/security/credentials_posix.c b/src/core/security/credentials_posix.c
index 79622cb024..20f67a7f14 100644
--- a/src/core/security/credentials_posix.c
+++ b/src/core/security/credentials_posix.c
@@ -39,6 +39,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/env.h"
#include "src/core/support/string.h"
diff --git a/src/core/security/credentials_win32.c b/src/core/security/credentials_win32.c
index ddb310468b..92dfd9bdfe 100644
--- a/src/core/security/credentials_win32.c
+++ b/src/core/security/credentials_win32.c
@@ -39,6 +39,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/env.h"
#include "src/core/support/string.h"
diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c
index eadae33609..6116f1d767 100644
--- a/src/core/security/json_token.c
+++ b/src/core/security/json_token.c
@@ -37,6 +37,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/security/base64.h"
#include "src/core/support/string.h"
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index 11505f8cb0..4098636a2e 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -47,6 +47,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
+#include <grpc/support/string_util.h>
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index 14c194c8f6..9aba1e7f91 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -40,6 +40,7 @@
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
/* --- grpc_call --- */
diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c
index 1823f75808..b19160b8ed 100644
--- a/src/core/security/server_auth_filter.c
+++ b/src/core/security/server_auth_filter.c
@@ -78,7 +78,6 @@ static void init_call_elem(grpc_call_element *elem,
calld->unused = 0;
GPR_ASSERT(initial_op && initial_op->context != NULL &&
- chand->security_connector->auth_context != NULL &&
initial_op->context[GRPC_CONTEXT_SECURITY].value == NULL);
/* Create a security context for the call and reference the auth context from
diff --git a/src/core/support/cmdline.c b/src/core/support/cmdline.c
index 530952c437..4baad85040 100644
--- a/src/core/support/cmdline.c
+++ b/src/core/support/cmdline.c
@@ -40,6 +40,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype;
diff --git a/src/core/support/env_linux.c b/src/core/support/env_linux.c
index bdadfb6ca4..2e03365e33 100644
--- a/src/core/support/env_linux.c
+++ b/src/core/support/env_linux.c
@@ -45,6 +45,7 @@
#include <stdlib.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/string.h"
diff --git a/src/core/support/env_posix.c b/src/core/support/env_posix.c
index 45f89b6737..1dd2af56bc 100644
--- a/src/core/support/env_posix.c
+++ b/src/core/support/env_posix.c
@@ -42,6 +42,7 @@
#include <grpc/support/log.h>
#include "src/core/support/string.h"
+#include <grpc/support/string_util.h>
char *gpr_getenv(const char *name) {
char *result = getenv(name);
diff --git a/src/core/support/env_win32.c b/src/core/support/env_win32.c
index 9b4cd698ad..6b1ff102b0 100644
--- a/src/core/support/env_win32.c
+++ b/src/core/support/env_win32.c
@@ -42,6 +42,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
char *gpr_getenv(const char *name) {
size_t size;
diff --git a/src/core/support/file.c b/src/core/support/file.c
index 3a4ac6f2f0..8ce7a67fb1 100644
--- a/src/core/support/file.c
+++ b/src/core/support/file.c
@@ -38,6 +38,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/string.h"
diff --git a/src/core/support/file_posix.c b/src/core/support/file_posix.c
index 11a459ad36..c11c07148a 100644
--- a/src/core/support/file_posix.c
+++ b/src/core/support/file_posix.c
@@ -44,6 +44,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/string.h"
diff --git a/src/core/support/file_win32.c b/src/core/support/file_win32.c
index f59d3af397..355744f79a 100644
--- a/src/core/support/file_win32.c
+++ b/src/core/support/file_win32.c
@@ -42,6 +42,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/support/file.h"
#include "src/core/support/string_win32.h"
diff --git a/src/core/support/host_port.c b/src/core/support/host_port.c
index fa49f1a33a..53669f063b 100644
--- a/src/core/support/host_port.c
+++ b/src/core/support/host_port.c
@@ -38,6 +38,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
int gpr_join_host_port(char **out, const char *host, int port) {
if (host[0] != '[' && strchr(host, ':') != NULL) {
diff --git a/src/core/support/string.h b/src/core/support/string.h
index faf3342708..31e9fcb5e9 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -44,10 +44,6 @@ extern "C" {
/* String utility functions */
-/* Returns a copy of src that can be passed to gpr_free().
- If allocation fails or if src is NULL, returns NULL. */
-char *gpr_strdup(const char *src);
-
/* flag to include plaintext after a hexdump */
#define GPR_HEXDUMP_PLAINTEXT 0x00000001
@@ -71,16 +67,6 @@ int gpr_ltoa(long value, char *output);
/* Reverse a run of bytes */
void gpr_reverse_bytes(char *str, int len);
-/* printf to a newly-allocated string. The set of supported formats may vary
- between platforms.
-
- On success, returns the number of bytes printed (excluding the final '\0'),
- and *strp points to a string which must later be destroyed with gpr_free().
-
- On error, returns -1 and sets *strp to NULL. If the format string is bad,
- the result is undefined. */
-int gpr_asprintf(char **strp, const char *format, ...);
-
/* Join a set of strings, returning the resulting string.
Total combined length (excluding null terminator) is returned in total_length
if it is non-null. */
diff --git a/src/core/surface/byte_buffer_reader.c b/src/core/surface/byte_buffer_reader.c
index fd5289bac3..41ad700274 100644
--- a/src/core/surface/byte_buffer_reader.c
+++ b/src/core/surface/byte_buffer_reader.c
@@ -39,15 +39,18 @@
#include <grpc/support/slice_buffer.h>
#include <grpc/byte_buffer.h>
-grpc_byte_buffer_reader *grpc_byte_buffer_reader_create(
- grpc_byte_buffer *buffer) {
- grpc_byte_buffer_reader *reader = malloc(sizeof(grpc_byte_buffer_reader));
+void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
+ grpc_byte_buffer *buffer) {
reader->buffer = buffer;
switch (buffer->type) {
case GRPC_BB_SLICE_BUFFER:
reader->current.index = 0;
}
- return reader;
+}
+
+void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) {
+ /* no-op: the user is responsible for memory deallocation.
+ * Other cleanup operations would go here if needed. */
}
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
@@ -68,7 +71,3 @@ int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
}
return 0;
}
-
-void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) {
- free(reader);
-}
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 88ff5cfbce..74df5745b5 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -42,6 +42,7 @@
#include "src/core/surface/completion_queue.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <assert.h>
#include <stdio.h>
diff --git a/src/core/surface/call_log_batch.c b/src/core/surface/call_log_batch.c
index 9905401bee..55663298c9 100644
--- a/src/core/surface/call_log_batch.c
+++ b/src/core/surface/call_log_batch.c
@@ -35,6 +35,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
int grpc_trace_batch = 0;
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index 9fa6696bf6..946ee0949d 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -53,6 +53,7 @@
#include "src/core/transport/chttp2_transport.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
diff --git a/src/core/surface/event_string.c b/src/core/surface/event_string.c
index 448bb1162b..33cd4a43aa 100644
--- a/src/core/surface/event_string.c
+++ b/src/core/surface/event_string.c
@@ -37,6 +37,7 @@
#include "src/core/support/string.h"
#include <grpc/byte_buffer.h>
+#include <grpc/support/string_util.h>
static void addhdr(gpr_strvec *buf, grpc_event *ev) {
char *tmp;
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index 8ef121dc48..8b39934881 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -56,6 +56,7 @@
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
#include "src/core/tsi/transport_security_interface.h"
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index f4aa6d5b2a..f9172d9850 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -48,6 +48,7 @@
#include "src/core/transport/metadata.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
typedef enum { PENDING_START, ALL_CALLS, CALL_LIST_COUNT } call_list;
diff --git a/src/core/transport/transport_op_string.c b/src/core/transport/transport_op_string.c
index 7bbe8276c3..5c4edb006a 100644
--- a/src/core/transport/transport_op_string.c
+++ b/src/core/transport/transport_op_string.c
@@ -39,6 +39,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
/* These routines are here to facilitate debugging - they produce string
diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc
index b9554c4bb7..7a7e73bba4 100644
--- a/src/cpp/proto/proto_utils.cc
+++ b/src/cpp/proto/proto_utils.cc
@@ -36,6 +36,7 @@
#include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
+#include <grpc/byte_buffer_reader.h>
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/port_platform.h>
@@ -100,11 +101,9 @@ class GrpcBufferReader GRPC_FINAL
public:
explicit GrpcBufferReader(grpc_byte_buffer* buffer)
: byte_count_(0), backup_count_(0) {
- reader_ = grpc_byte_buffer_reader_create(buffer);
- }
- ~GrpcBufferReader() GRPC_OVERRIDE {
- grpc_byte_buffer_reader_destroy(reader_);
+ grpc_byte_buffer_reader_init(&reader_, buffer);
}
+ ~GrpcBufferReader() GRPC_OVERRIDE {}
bool Next(const void** data, int* size) GRPC_OVERRIDE {
if (backup_count_ > 0) {
@@ -114,7 +113,7 @@ class GrpcBufferReader GRPC_FINAL
backup_count_ = 0;
return true;
}
- if (!grpc_byte_buffer_reader_next(reader_, &slice_)) {
+ if (!grpc_byte_buffer_reader_next(&reader_, &slice_)) {
return false;
}
gpr_slice_unref(slice_);
@@ -147,7 +146,7 @@ class GrpcBufferReader GRPC_FINAL
private:
gpr_int64 byte_count_;
gpr_int64 backup_count_;
- grpc_byte_buffer_reader* reader_;
+ grpc_byte_buffer_reader reader_;
gpr_slice slice_;
};
diff --git a/src/cpp/server/create_default_thread_pool.cc b/src/cpp/server/create_default_thread_pool.cc
new file mode 100644
index 0000000000..89c1d7e929
--- /dev/null
+++ b/src/cpp/server/create_default_thread_pool.cc
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include <grpc/support/cpu.h>
+#include "src/cpp/server/thread_pool.h"
+
+#ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL
+
+namespace grpc {
+
+ThreadPoolInterface* CreateDefaultThreadPool() {
+ int cores = gpr_cpu_num_cores();
+ if (!cores) cores = 4;
+ return new ThreadPool(cores);
+}
+
+} // namespace grpc
+
+#endif // !GRPC_CUSTOM_DEFAULT_THREAD_POOL
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index 4bcbd82952..3ee1d54e76 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -87,9 +87,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
return nullptr;
}
if (!thread_pool_ && !services_.empty()) {
- int cores = gpr_cpu_num_cores();
- if (!cores) cores = 4;
- thread_pool_ = new ThreadPool(cores);
+ thread_pool_ = CreateDefaultThreadPool();
thread_pool_owned = true;
}
std::unique_ptr<Server> server(
diff --git a/src/cpp/server/thread_pool.h b/src/cpp/server/thread_pool.h
index 26f25611b5..3b70249bf9 100644
--- a/src/cpp/server/thread_pool.h
+++ b/src/cpp/server/thread_pool.h
@@ -62,6 +62,8 @@ class ThreadPool GRPC_FINAL : public ThreadPoolInterface {
void ThreadFunc();
};
+ThreadPoolInterface* CreateDefaultThreadPool();
+
} // namespace grpc
#endif // GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H
diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc
index ac2657472c..45eaa2fe5b 100644
--- a/src/cpp/util/byte_buffer.cc
+++ b/src/cpp/util/byte_buffer.cc
@@ -31,6 +31,7 @@
*
*/
+#include <grpc/byte_buffer_reader.h>
#include <grpc++/byte_buffer.h>
namespace grpc {
@@ -56,12 +57,12 @@ void ByteBuffer::Dump(std::vector<Slice>* slices) {
if (!buffer_) {
return;
}
- grpc_byte_buffer_reader* reader = grpc_byte_buffer_reader_create(buffer_);
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader,buffer_);
gpr_slice s;
- while (grpc_byte_buffer_reader_next(reader, &s)) {
+ while (grpc_byte_buffer_reader_next(&reader, &s)) {
slices->push_back(Slice(s, Slice::STEAL_REF));
}
- grpc_byte_buffer_reader_destroy(reader);
}
size_t ByteBuffer::Length() {
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index 173e5c8a46..dc1bbe36f0 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -33,10 +33,12 @@
#include "src/core/support/string.h"
+#include <grpc/byte_buffer_reader.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@@ -236,13 +238,13 @@ GPR_EXPORT gpr_intptr GPR_CALLTYPE grpcsharp_batch_context_recv_message_length(
*/
GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer(
const grpcsharp_batch_context *ctx, char *buffer, size_t buffer_len) {
- grpc_byte_buffer_reader *reader;
+ grpc_byte_buffer_reader reader;
gpr_slice slice;
size_t offset = 0;
- reader = grpc_byte_buffer_reader_create(ctx->recv_message);
+ grpc_byte_buffer_reader_init(&reader, ctx->recv_message);
- while (grpc_byte_buffer_reader_next(reader, &slice)) {
+ while (grpc_byte_buffer_reader_next(&reader, &slice)) {
size_t len = GPR_SLICE_LENGTH(slice);
GPR_ASSERT(offset + len <= buffer_len);
memcpy(buffer + offset, GPR_SLICE_START_PTR(slice),
@@ -250,7 +252,6 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer(
offset += len;
gpr_slice_unref(slice);
}
- grpc_byte_buffer_reader_destroy(reader);
}
GPR_EXPORT grpc_status_code GPR_CALLTYPE
diff --git a/src/node/README.md b/src/node/README.md
index 6e4934151e..2f4c49096d 100644
--- a/src/node/README.md
+++ b/src/node/README.md
@@ -1,16 +1,22 @@
# Node.js gRPC Library
## Status
-
Alpha : Ready for early adopters
-## Prerequisites
-
-This requires `node` to be installed. If you instead have the `nodejs` executable on Debian, you should install the [`nodejs-legacy`](https://packages.debian.org/sid/nodejs-legacy) package.
+## PREREQUISITES
+- `node`: This requires `node` to be installed. If you instead have the `nodejs` executable on Debian, you should install the [`nodejs-legacy`](https://packages.debian.org/sid/nodejs-legacy) package.
+- [homebrew][] on Mac OS X, [linuxbrew][] on Linux. These simplify the installation of the gRPC C core.
-## Installation
+## INSTALLATION
+On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][].
+Run the following command to install gRPC Node.js.
+```sh
+$ curl -fsSL https://goo.gl/getgrpc | bash -s nodejs
+```
+This will download and run the [gRPC install script][], then install the latest version of gRPC Nodejs npm package.
- 1. Clone [the grpc repository](https://github.com/grpc/grpc).
+## BUILD FROM SOURCE
+ 1. Clone [the grpc Git Repository](https://github.com/grpc/grpc).
2. Follow the instructions in the `INSTALL` file in the root of that repository to install the C core library that this package depends on.
3. Run `npm install`.
@@ -20,12 +26,10 @@ If you install the gRPC C core library in a custom location, then you need to se
CXXFLAGS=-I<custom location>/include LDFLAGS=-L<custom location>/lib npm install [grpc]
```
-## Tests
-
+## TESTING
To run the test suite, simply run `npm test` in the install location.
## API
-
This library internally uses [ProtoBuf.js](https://github.com/dcodeIO/ProtoBuf.js), and some structures it exports match those exported by that library
If you require this module, you will get an object with the following members
@@ -82,3 +86,7 @@ ServerCredentials
```
An object with factory methods fro creating credential objects for servers.
+
+[homebrew]:http://brew.sh
+[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
+[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
diff --git a/src/node/cli/service_packager.js b/src/node/cli/service_packager.js
index f29180b252..c92c450a01 100644
--- a/src/node/cli/service_packager.js
+++ b/src/node/cli/service_packager.js
@@ -36,7 +36,7 @@
var fs = require('fs');
var path = require('path');
-var _ = require('underscore');
+var _ = require('lodash');
var async = require('async');
var pbjs = require('protobufjs/cli/pbjs');
var parseArgs = require('minimist');
diff --git a/src/node/examples/perf_test.js b/src/node/examples/perf_test.js
index 31083e0987..da919eced5 100644
--- a/src/node/examples/perf_test.js
+++ b/src/node/examples/perf_test.js
@@ -35,7 +35,7 @@
var grpc = require('..');
var testProto = grpc.load(__dirname + '/../interop/test.proto').grpc.testing;
-var _ = require('underscore');
+var _ = require('lodash');
var interop_server = require('../interop/interop_server.js');
function runTest(iterations, callback) {
diff --git a/src/node/examples/route_guide_client.js b/src/node/examples/route_guide_client.js
index 0b3e9c5819..8cd532fef1 100644
--- a/src/node/examples/route_guide_client.js
+++ b/src/node/examples/route_guide_client.js
@@ -37,7 +37,7 @@ var async = require('async');
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('..');
var examples = grpc.load(__dirname + '/route_guide.proto').examples;
var client = new examples.RouteGuide('localhost:50051');
diff --git a/src/node/examples/route_guide_server.js b/src/node/examples/route_guide_server.js
index 9555368422..c777eab7bc 100644
--- a/src/node/examples/route_guide_server.js
+++ b/src/node/examples/route_guide_server.js
@@ -36,7 +36,7 @@
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('..');
var examples = grpc.load(__dirname + '/route_guide.proto').examples;
diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js
index 8c22af147e..caaf9f99ba 100644
--- a/src/node/examples/stock_server.js
+++ b/src/node/examples/stock_server.js
@@ -33,7 +33,7 @@
'use strict';
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('..');
var examples = grpc.load(__dirname + '/stock.proto').examples;
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc
index 01bd92ea52..2c84099069 100644
--- a/src/node/ext/byte_buffer.cc
+++ b/src/node/ext/byte_buffer.cc
@@ -36,6 +36,7 @@
#include <node.h>
#include <nan.h>
#include "grpc/grpc.h"
+#include "grpc/byte_buffer_reader.h"
#include "grpc/support/slice.h"
#include "byte_buffer.h"
@@ -69,9 +70,10 @@ Handle<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
size_t length = grpc_byte_buffer_length(buffer);
char *result = reinterpret_cast<char *>(calloc(length, sizeof(char)));
size_t offset = 0;
- grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer);
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, buffer);
gpr_slice next;
- while (grpc_byte_buffer_reader_next(reader, &next) != 0) {
+ while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
}
diff --git a/src/node/index.js b/src/node/index.js
index c09e416c6e..b6a4e2d0ee 100644
--- a/src/node/index.js
+++ b/src/node/index.js
@@ -33,7 +33,7 @@
'use strict';
-var _ = require('underscore');
+var _ = require('lodash');
var ProtoBuf = require('protobufjs');
diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js
index 455055d9f3..b61b0b63c0 100644
--- a/src/node/interop/interop_client.js
+++ b/src/node/interop/interop_client.js
@@ -35,7 +35,7 @@
var fs = require('fs');
var path = require('path');
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('..');
var testProto = grpc.load(__dirname + '/test.proto').grpc.testing;
var GoogleAuth = require('google-auth-library');
diff --git a/src/node/interop/interop_server.js b/src/node/interop/interop_server.js
index dad59c1347..0baa78a094 100644
--- a/src/node/interop/interop_server.js
+++ b/src/node/interop/interop_server.js
@@ -35,7 +35,7 @@
var fs = require('fs');
var path = require('path');
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('..');
var testProto = grpc.load(__dirname + '/test.proto').grpc.testing;
var Server = grpc.buildServer([testProto.TestService.service]);
diff --git a/src/node/package.json b/src/node/package.json
index d7e9af07bd..3ea2c065e7 100644
--- a/src/node/package.json
+++ b/src/node/package.json
@@ -25,10 +25,9 @@
},
"dependencies": {
"bindings": "^1.2.0",
+ "lodash": "^3.9.3",
"nan": "^1.5.0",
- "protobufjs": "dcodeIO/ProtoBuf.js",
- "underscore": "^1.6.0",
- "underscore.string": "^3.0.0"
+ "protobufjs": "dcodeIO/ProtoBuf.js"
},
"devDependencies": {
"async": "^0.9.0",
diff --git a/src/node/src/client.js b/src/node/src/client.js
index 65339406b2..b7bad949d4 100644
--- a/src/node/src/client.js
+++ b/src/node/src/client.js
@@ -33,7 +33,7 @@
'use strict';
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('bindings')('grpc.node');
diff --git a/src/node/src/common.js b/src/node/src/common.js
index 98917c0fdd..7b543353eb 100644
--- a/src/node/src/common.js
+++ b/src/node/src/common.js
@@ -33,10 +33,7 @@
'use strict';
-var _ = require('underscore');
-
-var capitalize = require('underscore.string/capitalize');
-var decapitalize = require('underscore.string/decapitalize');
+var _ = require('lodash');
/**
* Get a function that deserializes a specific type of protobuf.
@@ -81,7 +78,7 @@ function fullyQualifiedName(value) {
}
var name = value.name;
if (value.className === 'Service.RPCMethod') {
- name = capitalize(name);
+ name = _.capitalize(name);
}
if (value.hasOwnProperty('parent')) {
var parent_name = fullyQualifiedName(value.parent);
@@ -118,8 +115,8 @@ function wrapIgnoreNull(func) {
function getProtobufServiceAttrs(service) {
var prefix = '/' + fullyQualifiedName(service) + '/';
return _.object(_.map(service.children, function(method) {
- return [decapitalize(method.name), {
- path: prefix + capitalize(method.name),
+ return [_.camelCase(method.name), {
+ path: prefix + _.capitalize(method.name),
requestStream: method.requestStream,
responseStream: method.responseStream,
requestSerialize: serializeCls(method.resolvedRequestType.build()),
diff --git a/src/node/src/server.js b/src/node/src/server.js
index 079495afd4..c6cf9e7eb8 100644
--- a/src/node/src/server.js
+++ b/src/node/src/server.js
@@ -33,7 +33,7 @@
'use strict';
-var _ = require('underscore');
+var _ = require('lodash');
var grpc = require('bindings')('grpc.node');
@@ -48,8 +48,6 @@ var util = require('util');
var EventEmitter = require('events').EventEmitter;
-var common = require('./common.js');
-
/**
* Handle an error on a call by sending it as a status
* @param {grpc.Call} call The call to send the error on
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index b390f8b2a5..8d1f99aaee 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -45,9 +45,7 @@ var math_proto = ProtoBuf.loadProtoFile(__dirname + '/../examples/math.proto');
var mathService = math_proto.lookup('math.Math');
-var capitalize = require('underscore.string/capitalize');
-
-var _ = require('underscore');
+var _ = require('lodash');
describe('File loader', function() {
it('Should load a proto file by default', function() {
@@ -159,7 +157,7 @@ describe('Generic client and server', function() {
server = new Server({
string: {
capitalize: function(call, callback) {
- callback(null, capitalize(call.request));
+ callback(null, _.capitalize(call.request));
}
}
});
diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m
index 6ea4ce979e..3a7f76887b 100644
--- a/src/objective-c/GRPCClient/private/NSData+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m
@@ -34,23 +34,26 @@
#import "NSData+GRPC.h"
#include <grpc/byte_buffer.h>
+#include <grpc/byte_buffer_reader.h>
#include <string.h>
// TODO(jcanizales): Move these two incantations to the C library.
static void CopyByteBufferToCharArray(grpc_byte_buffer *buffer, char *array) {
size_t offset = 0;
- grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer);
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, buffer);
gpr_slice next;
- while (grpc_byte_buffer_reader_next(reader, &next) != 0){
- memcpy(array + offset, GPR_SLICE_START_PTR(next), (size_t) GPR_SLICE_LENGTH(next));
+ while (grpc_byte_buffer_reader_next(&reader, &next) != 0){
+ memcpy(array + offset, GPR_SLICE_START_PTR(next),
+ (size_t)GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
gpr_slice_unref(next);
}
- grpc_byte_buffer_reader_destroy(reader);
}
-static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array, size_t length) {
+static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array,
+ size_t length) {
gpr_slice slice = gpr_slice_from_copied_buffer(array, length);
grpc_byte_buffer *buffer = grpc_byte_buffer_create(&slice, 1);
gpr_slice_unref(slice);
diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c
index 4f3e6b67af..bb9d3f5337 100644
--- a/src/php/ext/grpc/byte_buffer.c
+++ b/src/php/ext/grpc/byte_buffer.c
@@ -46,6 +46,7 @@
#include "byte_buffer.h"
#include <grpc/grpc.h>
+#include <grpc/byte_buffer_reader.h>
#include <grpc/support/slice.h>
grpc_byte_buffer *string_to_byte_buffer(char *string, size_t length) {
@@ -65,9 +66,10 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string,
size_t length = grpc_byte_buffer_length(buffer);
char *string = ecalloc(length + 1, sizeof(char));
size_t offset = 0;
- grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer);
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, buffer);
gpr_slice next;
- while (grpc_byte_buffer_reader_next(reader, &next) != 0) {
+ while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
}
diff --git a/src/python/README.md b/src/python/README.md
index c67201b670..0bca457a33 100644
--- a/src/python/README.md
+++ b/src/python/README.md
@@ -1,25 +1,30 @@
gRPC Python
=========
-
The Python facility of gRPC.
-
Status
-------
-
Alpha : Ready for early adopters
-Prerequisites
------------------------
-
-Python 2.7, virtualenv, pip, libprotobuf-dev, and libprotoc-dev.
-
+PREREQUISITES
+-------------
+- Python 2.7, virtualenv, pip
+- [homebrew][] on Mac OS X, [linuxbrew][] on Linux. These simplify the installation of the gRPC C core.
-Building from source
-----------------------
+INSTALLATION
+-------------
+On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][].
+Run the following command to install gRPC Python.
+```sh
+$ curl -fsSL https://goo.gl/getgrpc | bash -s python
+```
+This will download and run the [gRPC install script][], then install the latest version of the gRPC Python package. It also installs the Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin for python.
+BUILDING FROM SOURCE
+---------------------
+- Clone this repository
- Build the gRPC core from the root of the
- [gRPC git repo](https://github.com/grpc/grpc)
+ [gRPC Git repository](https://github.com/grpc/grpc)
```
$ make shared_c static_c
```
@@ -29,40 +34,16 @@ $ make shared_c static_c
$ tools/run_tests/build_python.sh
```
-
-Testing
------------------------
+TESTING
+-------
- Use run_python.sh to run gRPC as it was installed into the virtual environment
```
$ tools/run_tests/run_python.sh
```
-
-Installing
------------------------
-
-- Install the gRPC core
- - [Debian package](https://github.com/grpc/grpc/releases)
- ```
- $ wget https://github.com/grpc/grpc/releases/download/release-0_5_0/libgrpc_0.5.0_amd64.deb
- $ wget https://github.com/grpc/grpc/releases/download/release-0_5_0/libgrpc-dev_0.5.0_amd64.deb
- $ sudo dpkg -i libgrpc_0.5.0_amd64.deb libgrpc-dev_0.5.0_amd64.deb
- ```
- - [From source](https://github.com/grpc/grpc/blob/master/INSTALL)
-
-- Install gRPC Python's dependencies
-```
-$ pip install -r src/python/requirements.txt
-```
-
-- Install gRPC Python
-```
-$ pip install src/python/src
-```
-
-Packaging to PyPI
------------------------
+PACKAGING
+---------
- Install packaging dependencies
```
@@ -73,3 +54,7 @@ $ pip install setuptools twine
```
$ ../../tools/distrib/python/submit.py
```
+
+[homebrew]:http://brew.sh
+[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
+[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
diff --git a/src/python/src/grpc/_adapter/_c/utility.c b/src/python/src/grpc/_adapter/_c/utility.c
index 6d228c73fe..ced34a6816 100644
--- a/src/python/src/grpc/_adapter/_c/utility.c
+++ b/src/python/src/grpc/_adapter/_c/utility.c
@@ -36,6 +36,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <grpc/grpc.h>
+#include <grpc/byte_buffer_reader.h>
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
#include <grpc/support/time.h>
@@ -144,6 +145,11 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) {
static const int STATUS_INDEX = 4;
static const int STATUS_CODE_INDEX = 0;
static const int STATUS_DETAILS_INDEX = 1;
+ int type;
+ Py_ssize_t message_size;
+ char *message;
+ char *status_details;
+ gpr_slice message_slice;
grpc_op c_op;
if (!PyTuple_Check(op)) {
PyErr_SetString(PyExc_TypeError, "expected tuple op");
@@ -155,14 +161,10 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) {
PyErr_SetString(PyExc_ValueError, buf);
return 0;
}
- int type = PyInt_AsLong(PyTuple_GET_ITEM(op, TYPE_INDEX));
+ type = PyInt_AsLong(PyTuple_GET_ITEM(op, TYPE_INDEX));
if (PyErr_Occurred()) {
return 0;
}
- Py_ssize_t message_size;
- char *message;
- char *status_details;
- gpr_slice message_slice;
c_op.op = type;
switch (type) {
case GRPC_OP_SEND_INITIAL_METADATA:
@@ -365,7 +367,9 @@ gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds) {
int pygrpc_produce_channel_args(PyObject *py_args, grpc_channel_args *c_args) {
size_t num_args = PyList_Size(py_args);
size_t i;
- grpc_channel_args args = {num_args, gpr_malloc(sizeof(grpc_arg) * num_args)};
+ grpc_channel_args args;
+ args.num_args = num_args;
+ args.args = gpr_malloc(sizeof(grpc_arg) * num_args);
for (i = 0; i < args.num_args; ++i) {
char *key;
PyObject *value;
@@ -443,18 +447,18 @@ PyObject *pygrpc_cast_metadata_array_to_pylist(grpc_metadata_array metadata) {
void pygrpc_byte_buffer_to_bytes(
grpc_byte_buffer *buffer, char **result, size_t *result_size) {
- grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer);
+ grpc_byte_buffer_reader reader;
+ grpc_byte_buffer_reader_init(&reader, buffer);
gpr_slice slice;
char *read_result = NULL;
size_t size = 0;
- while (grpc_byte_buffer_reader_next(reader, &slice)) {
+ while (grpc_byte_buffer_reader_next(&reader, &slice)) {
read_result = gpr_realloc(read_result, size + GPR_SLICE_LENGTH(slice));
memcpy(read_result + size, GPR_SLICE_START_PTR(slice),
GPR_SLICE_LENGTH(slice));
size = size + GPR_SLICE_LENGTH(slice);
gpr_slice_unref(slice);
}
- grpc_byte_buffer_reader_destroy(reader);
*result_size = size;
*result = read_result;
}
diff --git a/src/python/src/grpc/_adapter/_links_test.py b/src/python/src/grpc/_adapter/_links_test.py
index 50257d8691..4729b84f84 100644
--- a/src/python/src/grpc/_adapter/_links_test.py
+++ b/src/python/src/grpc/_adapter/_links_test.py
@@ -40,7 +40,7 @@ from grpc.framework.base import interfaces
from grpc.framework.foundation import logging_pool
_IDENTITY = lambda x: x
-_TIMEOUT = 2
+_TIMEOUT = 32
# TODO(nathaniel): End-to-end metadata testing.
diff --git a/src/ruby/README.md b/src/ruby/README.md
index 9c0eef49b0..4b657c0bd4 100644
--- a/src/ruby/README.md
+++ b/src/ruby/README.md
@@ -4,48 +4,44 @@ gRPC Ruby
A Ruby implementation of gRPC.
Status
--------
+------
Alpha : Ready for early adopters
-INSTALLATION PREREQUISITES
---------------------------
+PREREQUISITES
+-------------
-This requires Ruby 2.1, as the RPC API surface uses keyword args.
+- Ruby 2.x. The gRPC API uses keyword args.
+- [homebrew][] on Mac OS X, [linuxbrew][] on Linux. These simplify the installation of the gRPC C core.
-
-QUICK - INSTALL
+INSTALLATION
---------------
-
-- Clone this repository.
-- Follow the instructions in [INSTALL](../../INSTALL) to install the gRPC C core.
-- If you don't have Ruby 2.1 installed, switch to the more detailed instructions below
-- Use bundler to install
+On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][].
+Run the following command to install gRPC Ruby.
```sh
-$ # from this directory
-$ gem install bundler && bundle install
+$ curl -fsSL https://goo.gl/getgrpc | bash -s ruby
```
+This will download and run the [gRPC install script][], then install the latest version of gRPC Ruby gem. It also installs Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin for ruby.
-Installing from source
-----------------------
-
+BUILD FROM SOURCE
+---------------------
+- Clone this repository
- Build the gRPC C core
-E.g, from the root of the gRPC [git repo](https://github.com/google/grpc)
+E.g, from the root of the gRPC [Git repository](https://github.com/google/grpc)
```sh
$ cd ../..
$ make && sudo make install
```
-- Install Ruby 2.1. Consider doing this with [RVM](http://rvm.io), it's a nice way of controlling
+- Install Ruby 2.x. Consider doing this with [RVM](http://rvm.io), it's a nice way of controlling
the exact ruby version that's used.
```sh
$ command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
-$ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-2.1
+$ \curl -sSL https://get.rvm.io | bash -s stable --ruby=ruby-2
$
$ # follow the instructions to ensure that your're using the latest stable version of Ruby
$ # and that the rvm command is installed
```
-
- Make sure your run `source $HOME/.rvm/scripts/rvm` as instructed to complete the set up of RVM
- Install [bundler](http://bundler.io/)
@@ -53,30 +49,36 @@ $ # and that the rvm command is installed
$ gem install bundler
```
-- Finally, install the gRPC gem locally.
+- Finally, build and install the gRPC gem locally.
```sh
$ # from this directory
$ bundle install # creates the ruby bundle, including building the grpc extension
$ rake # runs the unit tests, see rake -T for other options
```
+DOCUMENTATION
+-------------
+- rubydoc for the gRPC gem is available online at [rubydoc][].
+- the gRPC Ruby reference documentation is available online at [grpc.io][]
+
CONTENTS
--------
-
-Directory structure is the layout for [ruby extensions](http://guides.rubygems.org/gems-with-extensions/)
-
-- ext:
- the gRPC ruby extension
-- lib:
- the entrypoint gRPC ruby library to be used in a 'require' statement
-- spec:
- Rspec unittest
-- bin:
- example gRPC clients and servers, e.g,
-```ruby
-stub = Math::Math::Stub.new('my.test.math.server.com:8080')
-req = Math::DivArgs.new(dividend: 7, divisor: 3)
-logger.info("div(7/3): req=#{req.inspect}")
-resp = stub.div(req)
-logger.info("Answer: #{resp.inspect}")
-```
+Directory structure is the layout for [ruby extensions][]
+- ext: the gRPC ruby extension
+- lib: the entrypoint gRPC ruby library to be used in a 'require' statement
+- spec: Rspec unittests
+- bin: example gRPC clients and servers, e.g,
+
+ ```ruby
+ stub = Math::Math::Stub.new('my.test.math.server.com:8080')
+ req = Math::DivArgs.new(dividend: 7, divisor: 3)
+ GRPC.logger.info("div(7/3): req=#{req.inspect}")
+ resp = stub.div(req)
+ GRPC.logger.info("Answer: #{resp.inspect}")
+ ```
+[homebrew]:http://brew.sh
+[linuxbrew]:https://github.com/Homebrew/linuxbrew#installation
+[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
+[ruby extensions]:http://guides.rubygems.org/gems-with-extensions/
+[rubydoc]: http://www.rubydoc.info/gems/grpc
+[grpc.io]: http://www.grpc.io/docs/installation/ruby.html
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c
index edf0d3b115..1cc22f4aff 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.c
+++ b/src/ruby/ext/grpc/rb_byte_buffer.c
@@ -36,6 +36,7 @@
#include <ruby/ruby.h>
#include <grpc/grpc.h>
+#include <grpc/byte_buffer_reader.h>
#include <grpc/support/slice.h>
#include "rb_grpc.h"
@@ -50,7 +51,7 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
size_t length = 0;
char *string = NULL;
size_t offset = 0;
- grpc_byte_buffer_reader *reader = NULL;
+ grpc_byte_buffer_reader reader;
gpr_slice next;
if (buffer == NULL) {
return Qnil;
@@ -58,8 +59,8 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
}
length = grpc_byte_buffer_length(buffer);
string = xmalloc(length + 1);
- reader = grpc_byte_buffer_reader_create(buffer);
- while (grpc_byte_buffer_reader_next(reader, &next) != 0) {
+ grpc_byte_buffer_reader_init(&reader, buffer);
+ while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
}
diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb
index 40b6df9a2b..8588bfd808 100644
--- a/src/ruby/lib/grpc/version.rb
+++ b/src/ruby/lib/grpc/version.rb
@@ -29,5 +29,5 @@
# GRPC contains the General RPC module.
module GRPC
- VERSION = '0.9.0'
+ VERSION = '0.9.2'
end