Merge branch 'we-dont-need-no-backup' into one-shouldnt-depend-on-protobufs

pull/1969/head
Craig Tiller 10 years ago
commit c091d5f4cd
  1. 38
      gRPC.podspec
  2. 28
      include/grpc/grpc.h
  3. 11
      src/core/channel/child_channel.c
  4. 9
      src/core/channel/client_setup.c
  5. 6
      src/core/channel/client_setup.h
  6. 45
      src/core/debug/trace.c
  7. 1
      src/core/debug/trace.h
  8. 12
      src/core/iomgr/fd_posix.c
  9. 8
      src/core/iomgr/fd_posix.h
  10. 7
      src/core/iomgr/iomgr.c
  11. 3
      src/core/iomgr/pollset.h
  12. 14
      src/core/iomgr/pollset_kick_posix.c
  13. 14
      src/core/iomgr/pollset_kick_posix.h
  14. 12
      src/core/iomgr/pollset_multipoller_with_epoll.c
  15. 9
      src/core/iomgr/pollset_multipoller_with_poll_posix.c
  16. 2
      src/core/iomgr/pollset_posix.c
  17. 4
      src/core/iomgr/pollset_set_windows.h
  18. 8
      src/core/iomgr/pollset_windows.c
  19. 6
      src/core/iomgr/pollset_windows.h
  20. 2
      src/core/iomgr/resolve_address_windows.c
  21. 2
      src/core/iomgr/socket_windows.c
  22. 2
      src/core/iomgr/tcp_client.h
  23. 3
      src/core/iomgr/tcp_client_posix.c
  24. 18
      src/core/iomgr/tcp_client_windows.c
  25. 5
      src/core/iomgr/tcp_posix.c
  26. 5
      src/core/iomgr/tcp_server_posix.c
  27. 15
      src/core/security/client_auth_filter.c
  28. 19
      src/core/security/credentials.c
  29. 5
      src/core/security/credentials.h
  30. 4
      src/core/security/google_default_credentials.c
  31. 2
      src/core/surface/channel.c
  32. 3
      src/core/surface/channel_create.c
  33. 18
      src/core/surface/completion_queue.c
  34. 1
      src/core/surface/init.c
  35. 6
      src/core/surface/lame_client.c
  36. 9
      src/core/surface/secure_channel_create.c
  37. 4
      src/core/surface/server.c
  38. 63
      src/core/transport/chttp2_transport.c
  39. 120
      src/objective-c/README.md
  40. 1
      src/objective-c/examples/Sample/Podfile
  41. 33
      src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.h
  42. 59
      src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.m
  43. 221
      src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.h
  44. 603
      src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.m
  45. 32
      src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
  46. 12
      src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.h
  47. 9
      src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.m
  48. 59
      src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.h
  49. 96
      src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.m
  50. 134
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.h
  51. 355
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.m
  52. 43
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.h
  53. 72
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.m
  54. 26
      src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec
  55. 24
      src/objective-c/generated_libraries/RouteGuideClient/Route_guide.podspec
  56. 2
      src/objective-c/generated_libraries/RouteGuideClient/route_guide.proto
  57. 82
      src/objective-c/tests/LocalClearTextTests.m
  58. 3
      src/objective-c/tests/Podfile
  59. 47
      src/ruby/ext/grpc/extconf.rb
  60. 2
      src/ruby/grpc.gemspec
  61. 2
      src/ruby/lib/grpc/version.rb
  62. 4
      test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
  63. 36
      tools/jenkins/grpc_jenkins_slave/Dockerfile
  64. 4
      tools/jenkins/run_jenkins.sh
  65. 2
      tools/run_tests/build_node.sh

@ -13,23 +13,27 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.8' s.osx.deployment_target = '10.8'
s.requires_arc = true s.requires_arc = true
# Reactive Extensions library for iOS.
s.subspec 'RxLibrary' do |rs| s.subspec 'RxLibrary' do |rs|
rs.summary = 'Reactive Extensions library for iOS.'
rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}', rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
'src/objective-c/RxLibrary/transformations/*.{h,m}', 'src/objective-c/RxLibrary/transformations/*.{h,m}',
'src/objective-c/RxLibrary/private/*.{h,m}' 'src/objective-c/RxLibrary/private/*.{h,m}'
rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h' rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
end end
# Core cross-platform gRPC library, written in C.
s.subspec 'C-Core' do |cs| s.subspec 'C-Core' do |cs|
cs.summary = 'Core cross-platform gRPC library, written in C.'
cs.source_files = 'src/core/**/*.{h,c}', 'include/grpc/*.h', 'include/grpc/**/*.h' cs.source_files = 'src/core/**/*.{h,c}', 'include/grpc/*.h', 'include/grpc/**/*.h'
cs.private_header_files = 'src/core/**/*.h' cs.private_header_files = 'src/core/**/*.h'
cs.header_mappings_dir = '.' cs.header_mappings_dir = '.'
cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Build/gRPC" ' # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
'"$(PODS_ROOT)/Headers/Build/gRPC/include"' } # to tell XCode to look for headers under the "include" subdirectory too.
#
# TODO(jcanizales): Instead of doing this, during installation move everything under
# "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
# details of Cocoapods, and have changed in the past, breaking this podspec.
cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
'"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
cs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w' cs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
cs.requires_arc = false cs.requires_arc = false
@ -41,35 +45,38 @@ Pod::Spec.new do |s|
# It renames time.h and string.h to grpc_time.h and grpc_string.h. # It renames time.h and string.h to grpc_time.h and grpc_string.h.
# It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
# prepare_command's of subspecs. # prepare_command's of subspecs.
#
# TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
s.prepare_command = <<-CMD s.prepare_command = <<-CMD
DIR_TIME="grpc/support" DIR_TIME="grpc/support"
BAD_TIME="$DIR_TIME/time.h" BAD_TIME="$DIR_TIME/time.h"
GOOD_TIME="$DIR_TIME/grpc_time.h" GOOD_TIME="$DIR_TIME/grpc_time.h"
grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
if [ -f "include/$BAD_TIME" ]; if [ -f "include/$BAD_TIME" ];
then then
grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
mv "include/$BAD_TIME" "include/$GOOD_TIME"
fi fi
DIR_STRING="src/core/support" DIR_STRING="src/core/support"
BAD_STRING="$DIR_STRING/string.h" BAD_STRING="$DIR_STRING/string.h"
GOOD_STRING="$DIR_STRING/grpc_string.h" GOOD_STRING="$DIR_STRING/grpc_string.h"
grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
if [ -f "$BAD_STRING" ]; if [ -f "$BAD_STRING" ];
then then
grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g mv -f "$BAD_STRING" "$GOOD_STRING"
mv "$BAD_STRING" "$GOOD_STRING"
fi fi
CMD CMD
# Objective-C wrapper around the core gRPC library.
s.subspec 'GRPCClient' do |gs| s.subspec 'GRPCClient' do |gs|
gs.summary = 'Objective-C wrapper around the core gRPC library.'
gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}', gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
'src/objective-c/GRPCClient/private/*.{h,m}' 'src/objective-c/GRPCClient/private/*.{h,m}'
gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h' gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
gs.dependency 'gRPC/C-Core' gs.dependency 'gRPC/C-Core'
# Is this needed in all dependents? # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
# one directory up.
gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' } gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
gs.dependency 'gRPC/RxLibrary' gs.dependency 'gRPC/RxLibrary'
@ -77,13 +84,12 @@ Pod::Spec.new do |s|
gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] } gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
end end
# RPC library for ProtocolBuffers, based on gRPC
s.subspec 'ProtoRPC' do |ps| s.subspec 'ProtoRPC' do |ps|
ps.summary = 'RPC library for ProtocolBuffers, based on gRPC'
ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}' ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
ps.dependency 'gRPC/GRPCClient' ps.dependency 'gRPC/GRPCClient'
ps.dependency 'gRPC/RxLibrary' ps.dependency 'gRPC/RxLibrary'
ps.dependency 'Protobuf', '~> 3.0' ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
end end
end end

@ -200,11 +200,11 @@ typedef struct grpc_metadata {
/** The type of completion (for grpc_event) */ /** The type of completion (for grpc_event) */
typedef enum grpc_completion_type { typedef enum grpc_completion_type {
/** Shutting down */ /** Shutting down */
GRPC_QUEUE_SHUTDOWN, GRPC_QUEUE_SHUTDOWN,
/** No event before timeout */ /** No event before timeout */
GRPC_QUEUE_TIMEOUT, GRPC_QUEUE_TIMEOUT,
/** Operation completion */ /** Operation completion */
GRPC_OP_COMPLETE GRPC_OP_COMPLETE
} grpc_completion_type; } grpc_completion_type;
/** The result of an operation. /** The result of an operation.
@ -213,7 +213,7 @@ typedef enum grpc_completion_type {
typedef struct grpc_event { typedef struct grpc_event {
/** The type of the completion. */ /** The type of the completion. */
grpc_completion_type type; grpc_completion_type type;
/** non-zero if the operation was successful, 0 upon failure. /** non-zero if the operation was successful, 0 upon failure.
Only GRPC_OP_COMPLETE can succeed or fail. */ Only GRPC_OP_COMPLETE can succeed or fail. */
int success; int success;
/** The tag passed to grpc_call_start_batch etc to start this operation. /** The tag passed to grpc_call_start_batch etc to start this operation.
@ -340,7 +340,7 @@ typedef struct grpc_op {
} grpc_op; } grpc_op;
/** Initialize the grpc library. /** Initialize the grpc library.
It is not safe to call any other grpc functions before calling this. It is not safe to call any other grpc functions before calling this.
(To avoid overhead, little checking is done, and some things may work. We (To avoid overhead, little checking is done, and some things may work. We
do not warrant that they will continue to do so in future revisions of this do not warrant that they will continue to do so in future revisions of this
@ -348,7 +348,7 @@ typedef struct grpc_op {
void grpc_init(void); void grpc_init(void);
/** Shut down the grpc library. /** Shut down the grpc library.
No memory is used by grpc after this call returns, nor are any instructions No memory is used by grpc after this call returns, nor are any instructions
executing within the grpc library. executing within the grpc library.
Prior to calling, all application owned grpc objects must have been Prior to calling, all application owned grpc objects must have been
@ -359,7 +359,7 @@ void grpc_shutdown(void);
grpc_completion_queue *grpc_completion_queue_create(void); grpc_completion_queue *grpc_completion_queue_create(void);
/** Blocks until an event is available, the completion queue is being shut down, /** Blocks until an event is available, the completion queue is being shut down,
or deadline is reached. or deadline is reached.
Returns NULL on timeout, otherwise the event that occurred. Returns NULL on timeout, otherwise the event that occurred.
@ -369,7 +369,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
gpr_timespec deadline); gpr_timespec deadline);
/** Blocks until an event with tag 'tag' is available, the completion queue is /** Blocks until an event with tag 'tag' is available, the completion queue is
being shutdown or deadline is reached. being shutdown or deadline is reached.
Returns NULL on timeout, or a pointer to the event that occurred. Returns NULL on timeout, or a pointer to the event that occurred.
@ -516,7 +516,7 @@ void grpc_server_start(grpc_server *server);
void grpc_server_shutdown_and_notify(grpc_server *server, void grpc_server_shutdown_and_notify(grpc_server *server,
grpc_completion_queue *cq, void *tag); grpc_completion_queue *cq, void *tag);
/* Cancel all in-progress calls. /* Cancel all in-progress calls.
Only usable after shutdown. */ Only usable after shutdown. */
void grpc_server_cancel_all_calls(grpc_server *server); void grpc_server_cancel_all_calls(grpc_server *server);
@ -526,6 +526,16 @@ void grpc_server_cancel_all_calls(grpc_server *server);
one call to grpc_server_shutdown_and_notify must have been made). */ one call to grpc_server_shutdown_and_notify must have been made). */
void grpc_server_destroy(grpc_server *server); void grpc_server_destroy(grpc_server *server);
/** Enable or disable a tracer.
Tracers (usually controlled by the environment variable GRPC_TRACE)
allow printf-style debugging on GRPC internals, and are useful for
tracking down problems in the field.
Use of this function is not strictly thread-safe, but the
thread-safety issues raised by it should not be of concern. */
int grpc_tracer_set_enabled(const char *name, int enabled);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -157,16 +157,11 @@ static void lb_destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_child_channel_top_filter = { const grpc_channel_filter grpc_child_channel_top_filter = {
lb_start_transport_op, lb_start_transport_op, lb_channel_op,
lb_channel_op,
sizeof(lb_call_data), sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem,
lb_init_call_elem,
lb_destroy_call_elem,
sizeof(lb_channel_data), sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem,
lb_init_channel_elem,
lb_destroy_channel_elem,
"child-channel", "child-channel",
}; };

@ -179,7 +179,8 @@ static void setup_cancel(grpc_transport_setup *sp) {
} }
} }
int grpc_client_setup_cb_begin(grpc_client_setup_request *r, const char *reason) { int grpc_client_setup_cb_begin(grpc_client_setup_request *r,
const char *reason) {
gpr_mu_lock(&r->setup->mu); gpr_mu_lock(&r->setup->mu);
if (r->setup->cancelled) { if (r->setup->cancelled) {
gpr_mu_unlock(&r->setup->mu); gpr_mu_unlock(&r->setup->mu);
@ -190,7 +191,8 @@ int grpc_client_setup_cb_begin(grpc_client_setup_request *r, const char *reason)
return 1; return 1;
} }
void grpc_client_setup_cb_end(grpc_client_setup_request *r, const char *reason) { void grpc_client_setup_cb_end(grpc_client_setup_request *r,
const char *reason) {
gpr_mu_lock(&r->setup->mu); gpr_mu_lock(&r->setup->mu);
r->setup->in_cb--; r->setup->in_cb--;
if (r->setup->cancelled) gpr_cv_signal(&r->setup->cv); if (r->setup->cancelled) gpr_cv_signal(&r->setup->cv);
@ -227,7 +229,8 @@ void grpc_client_setup_create_and_attach(
grpc_client_channel_set_transport_setup(newly_minted_channel, &s->base); grpc_client_channel_set_transport_setup(newly_minted_channel, &s->base);
} }
int grpc_client_setup_request_should_continue(grpc_client_setup_request *r, const char *reason) { int grpc_client_setup_request_should_continue(grpc_client_setup_request *r,
const char *reason) {
int result; int result;
if (gpr_time_cmp(gpr_now(), r->deadline) > 0) { if (gpr_time_cmp(gpr_now(), r->deadline) > 0) {
result = 0; result = 0;

@ -52,7 +52,8 @@ void grpc_client_setup_create_and_attach(
/* Check that r is the active request: needs to be performed at each callback. /* Check that r is the active request: needs to be performed at each callback.
If this races, we'll have two connection attempts running at once and the If this races, we'll have two connection attempts running at once and the
old one will get cleaned up in due course, which is fine. */ old one will get cleaned up in due course, which is fine. */
int grpc_client_setup_request_should_continue(grpc_client_setup_request *r, const char *reason); int grpc_client_setup_request_should_continue(grpc_client_setup_request *r,
const char *reason);
void grpc_client_setup_request_finish(grpc_client_setup_request *r, void grpc_client_setup_request_finish(grpc_client_setup_request *r,
int was_successful); int was_successful);
const grpc_channel_args *grpc_client_setup_get_channel_args( const grpc_channel_args *grpc_client_setup_get_channel_args(
@ -61,7 +62,8 @@ const grpc_channel_args *grpc_client_setup_get_channel_args(
/* Call before calling back into the setup listener, and call only if /* Call before calling back into the setup listener, and call only if
this function returns 1. If it returns 1, also promise to call this function returns 1. If it returns 1, also promise to call
grpc_client_setup_cb_end */ grpc_client_setup_cb_end */
int grpc_client_setup_cb_begin(grpc_client_setup_request *r, const char *reason); int grpc_client_setup_cb_begin(grpc_client_setup_request *r,
const char *reason);
void grpc_client_setup_cb_end(grpc_client_setup_request *r, const char *reason); void grpc_client_setup_cb_end(grpc_client_setup_request *r, const char *reason);
/* Get the deadline for a request passed in to initiate. Implementations should /* Get the deadline for a request passed in to initiate. Implementations should

@ -35,6 +35,7 @@
#include <string.h> #include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/support/env.h" #include "src/core/support/env.h"
@ -80,27 +81,10 @@ static void parse(const char *s) {
char **strings = NULL; char **strings = NULL;
size_t nstrings = 0; size_t nstrings = 0;
size_t i; size_t i;
tracer *t;
split(s, &strings, &nstrings); split(s, &strings, &nstrings);
for (i = 0; i < nstrings; i++) { for (i = 0; i < nstrings; i++) {
const char *s = strings[i]; grpc_tracer_set_enabled(strings[i], 1);
if (0 == strcmp(s, "all")) {
for (t = tracers; t; t = t->next) {
*t->flag = 1;
}
} else {
int found = 0;
for (t = tracers; t; t = t->next) {
if (0 == strcmp(s, t->name)) {
*t->flag = 1;
found = 1;
}
}
if (!found) {
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", s);
}
}
} }
for (i = 0; i < nstrings; i++) { for (i = 0; i < nstrings; i++) {
@ -115,9 +99,34 @@ void grpc_tracer_init(const char *env_var) {
parse(e); parse(e);
gpr_free(e); gpr_free(e);
} }
}
void grpc_tracer_shutdown(void) {
while (tracers) { while (tracers) {
tracer *t = tracers; tracer *t = tracers;
tracers = t->next; tracers = t->next;
gpr_free(t); gpr_free(t);
} }
} }
int grpc_tracer_set_enabled(const char *name, int enabled) {
tracer *t;
if (0 == strcmp(name, "all")) {
for (t = tracers; t; t = t->next) {
*t->flag = 1;
}
} else {
int found = 0;
for (t = tracers; t; t = t->next) {
if (0 == strcmp(name, t->name)) {
*t->flag = enabled;
found = 1;
}
}
if (!found) {
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
return 0; /* early return */
}
}
return 1;
}

@ -38,5 +38,6 @@
void grpc_register_tracer(const char *name, int *flag); void grpc_register_tracer(const char *name, int *flag);
void grpc_tracer_init(const char *env_var_name); void grpc_tracer_init(const char *env_var_name);
void grpc_tracer_shutdown(void);
#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */ #endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */

@ -112,7 +112,8 @@ static void destroy(grpc_fd *fd) {
#ifdef GRPC_FD_REF_COUNT_DEBUG #ifdef GRPC_FD_REF_COUNT_DEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__) #define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__) #define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file, int line) { static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
int line) {
gpr_log(GPR_DEBUG, "FD %d %p ref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n, gpr_log(GPR_DEBUG, "FD %d %p ref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n,
gpr_atm_no_barrier_load(&fd->refst), gpr_atm_no_barrier_load(&fd->refst),
gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line); gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line);
@ -125,7 +126,8 @@ static void ref_by(grpc_fd *fd, int n) {
} }
#ifdef GRPC_FD_REF_COUNT_DEBUG #ifdef GRPC_FD_REF_COUNT_DEBUG
static void unref_by(grpc_fd *fd, int n, const char *reason, const char *file, int line) { static void unref_by(grpc_fd *fd, int n, const char *reason, const char *file,
int line) {
gpr_atm old; gpr_atm old;
gpr_log(GPR_DEBUG, "FD %d %p unref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n, gpr_log(GPR_DEBUG, "FD %d %p unref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n,
gpr_atm_no_barrier_load(&fd->refst), gpr_atm_no_barrier_load(&fd->refst),
@ -225,7 +227,7 @@ void grpc_fd_unref(grpc_fd *fd) { unref_by(fd, 2); }
#endif #endif
static void process_callback(grpc_iomgr_closure *closure, int success, static void process_callback(grpc_iomgr_closure *closure, int success,
int allow_synchronous_callback) { int allow_synchronous_callback) {
if (allow_synchronous_callback) { if (allow_synchronous_callback) {
closure->cb(closure->cb_arg, success); closure->cb(closure->cb_arg, success);
} else { } else {
@ -265,7 +267,7 @@ static void notify_on(grpc_fd *fd, gpr_atm *st, grpc_iomgr_closure *closure,
GPR_ASSERT(gpr_atm_no_barrier_load(st) == READY); GPR_ASSERT(gpr_atm_no_barrier_load(st) == READY);
gpr_atm_rel_store(st, NOT_READY); gpr_atm_rel_store(st, NOT_READY);
process_callback(closure, !gpr_atm_acq_load(&fd->shutdown), process_callback(closure, !gpr_atm_acq_load(&fd->shutdown),
allow_synchronous_callback); allow_synchronous_callback);
return; return;
default: /* WAITING */ default: /* WAITING */
/* upcallptr was set to a different closure. This is an error! */ /* upcallptr was set to a different closure. This is an error! */
@ -309,7 +311,7 @@ static void set_ready(grpc_fd *fd, gpr_atm *st,
/* only one set_ready can be active at once (but there may be a racing /* only one set_ready can be active at once (but there may be a racing
notify_on) */ notify_on) */
int success; int success;
grpc_iomgr_closure* closure; grpc_iomgr_closure *closure;
size_t ncb = 0; size_t ncb = 0;
gpr_mu_lock(&fd->set_state_mu); gpr_mu_lock(&fd->set_state_mu);

@ -62,12 +62,12 @@ struct grpc_fd {
gpr_atm shutdown; gpr_atm shutdown;
/* The watcher list. /* The watcher list.
The following watcher related fields are protected by watcher_mu. The following watcher related fields are protected by watcher_mu.
An fd_watcher is an ephemeral object created when an fd wants to An fd_watcher is an ephemeral object created when an fd wants to
begin polling, and destroyed after the poll. begin polling, and destroyed after the poll.
It denotes the fd's interest in whether to read poll or write poll It denotes the fd's interest in whether to read poll or write poll
or both or neither on this fd. or both or neither on this fd.
@ -175,4 +175,4 @@ void grpc_fd_unref(grpc_fd *fd);
void grpc_fd_global_init(void); void grpc_fd_global_init(void);
void grpc_fd_global_shutdown(void); void grpc_fd_global_shutdown(void);
#endif /* GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H */

@ -144,8 +144,8 @@ void grpc_iomgr_shutdown(void) {
} }
if (g_root_object.next != &g_root_object) { if (g_root_object.next != &g_root_object) {
int timeout = 0; int timeout = 0;
gpr_timespec short_deadline = gpr_time_add(gpr_now(), gpr_timespec short_deadline =
gpr_time_from_millis(100)); gpr_time_add(gpr_now(), gpr_time_from_millis(100));
while (gpr_cv_wait(&g_rcv, &g_mu, short_deadline) && g_cbs_head == NULL) { while (gpr_cv_wait(&g_rcv, &g_mu, short_deadline) && g_cbs_head == NULL) {
if (gpr_time_cmp(gpr_now(), shutdown_deadline) > 0) { if (gpr_time_cmp(gpr_now(), shutdown_deadline) > 0) {
timeout = 1; timeout = 1;
@ -194,7 +194,6 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) {
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
} }
void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb,
void *cb_arg) { void *cb_arg) {
closure->cb = cb; closure->cb = cb;
@ -218,12 +217,10 @@ void grpc_iomgr_add_delayed_callback(grpc_iomgr_closure *closure, int success) {
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
} }
void grpc_iomgr_add_callback(grpc_iomgr_closure *closure) { void grpc_iomgr_add_callback(grpc_iomgr_closure *closure) {
grpc_iomgr_add_delayed_callback(closure, 1 /* GPR_TRUE */); grpc_iomgr_add_delayed_callback(closure, 1 /* GPR_TRUE */);
} }
int grpc_maybe_call_delayed_callbacks(gpr_mu *drop_mu, int success) { int grpc_maybe_call_delayed_callbacks(gpr_mu *drop_mu, int success) {
int n = 0; int n = 0;
gpr_mu *retake_mu = NULL; gpr_mu *retake_mu = NULL;

@ -58,7 +58,6 @@ void grpc_pollset_shutdown(grpc_pollset *pollset,
void *shutdown_done_arg); void *shutdown_done_arg);
void grpc_pollset_destroy(grpc_pollset *pollset); void grpc_pollset_destroy(grpc_pollset *pollset);
/* Do some work on a pollset. /* Do some work on a pollset.
May involve invoking asynchronous callbacks, or actually polling file May involve invoking asynchronous callbacks, or actually polling file
descriptors. descriptors.
@ -70,4 +69,4 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline);
Requires GRPC_POLLSET_MU(pollset) locked. */ Requires GRPC_POLLSET_MU(pollset) locked. */
void grpc_pollset_kick(grpc_pollset *pollset); void grpc_pollset_kick(grpc_pollset *pollset);
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */

@ -73,7 +73,7 @@ static grpc_kick_fd_info *allocate_wfd(void) {
return info; return info;
} }
static void destroy_wfd(grpc_kick_fd_info* wfd) { static void destroy_wfd(grpc_kick_fd_info *wfd) {
grpc_wakeup_fd_destroy(&wfd->wakeup_fd); grpc_wakeup_fd_destroy(&wfd->wakeup_fd);
gpr_free(wfd); gpr_free(wfd);
} }
@ -104,7 +104,8 @@ void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state) {
GPR_ASSERT(kick_state->fd_list.next == &kick_state->fd_list); GPR_ASSERT(kick_state->fd_list.next == &kick_state->fd_list);
} }
grpc_kick_fd_info *grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { grpc_kick_fd_info *grpc_pollset_kick_pre_poll(
grpc_pollset_kick_state *kick_state) {
grpc_kick_fd_info *fd_info; grpc_kick_fd_info *fd_info;
gpr_mu_lock(&kick_state->mu); gpr_mu_lock(&kick_state->mu);
if (kick_state->kicked) { if (kick_state->kicked) {
@ -120,11 +121,13 @@ grpc_kick_fd_info *grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_stat
return fd_info; return fd_info;
} }
void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state, grpc_kick_fd_info *fd_info) { void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state,
grpc_kick_fd_info *fd_info) {
grpc_wakeup_fd_consume_wakeup(&fd_info->wakeup_fd); grpc_wakeup_fd_consume_wakeup(&fd_info->wakeup_fd);
} }
void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state, grpc_kick_fd_info *fd_info) { void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state,
grpc_kick_fd_info *fd_info) {
gpr_mu_lock(&kick_state->mu); gpr_mu_lock(&kick_state->mu);
fd_info->next->prev = fd_info->prev; fd_info->next->prev = fd_info->prev;
fd_info->prev->next = fd_info->next; fd_info->prev->next = fd_info->next;
@ -162,5 +165,4 @@ void grpc_pollset_kick_global_destroy(void) {
gpr_mu_destroy(&fd_freelist_mu); gpr_mu_destroy(&fd_freelist_mu);
} }
#endif /* GPR_POSIX_SOCKET */
#endif /* GPR_POSIX_SOCKET */

@ -51,7 +51,8 @@ typedef struct grpc_pollset_kick_state {
struct grpc_kick_fd_info fd_list; struct grpc_kick_fd_info fd_list;
} grpc_pollset_kick_state; } grpc_pollset_kick_state;
#define GRPC_POLLSET_KICK_GET_FD(kick_fd_info) GRPC_WAKEUP_FD_GET_READ_FD(&(kick_fd_info)->wakeup_fd) #define GRPC_POLLSET_KICK_GET_FD(kick_fd_info) \
GRPC_WAKEUP_FD_GET_READ_FD(&(kick_fd_info)->wakeup_fd)
/* This is an abstraction around the typical pipe mechanism for waking up a /* This is an abstraction around the typical pipe mechanism for waking up a
thread sitting in a poll() style call. */ thread sitting in a poll() style call. */
@ -69,15 +70,18 @@ void grpc_pollset_kick_global_init_fallback_fd(void);
/* Must be called before entering poll(). If return value is -1, this consumed /* Must be called before entering poll(). If return value is -1, this consumed
an existing kick. Otherwise the return value is an FD to add to the poll set. an existing kick. Otherwise the return value is an FD to add to the poll set.
*/ */
grpc_kick_fd_info *grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state); grpc_kick_fd_info *grpc_pollset_kick_pre_poll(
grpc_pollset_kick_state *kick_state);
/* Consume an existing kick. Must be called after poll returns that the fd was /* Consume an existing kick. Must be called after poll returns that the fd was
readable, and before calling kick_post_poll. */ readable, and before calling kick_post_poll. */
void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state, grpc_kick_fd_info *fd_info); void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state,
grpc_kick_fd_info *fd_info);
/* Must be called after pre_poll, and after consume if applicable */ /* Must be called after pre_poll, and after consume if applicable */
void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state, grpc_kick_fd_info *fd_info); void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state,
grpc_kick_fd_info *fd_info);
void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state); void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state);
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H */

@ -143,7 +143,8 @@ static int multipoll_with_epoll_pollset_maybe_work(
return 1; return 1;
} }
static void multipoll_with_epoll_pollset_finish_shutdown(grpc_pollset *pollset) {} static void multipoll_with_epoll_pollset_finish_shutdown(
grpc_pollset *pollset) {}
static void multipoll_with_epoll_pollset_destroy(grpc_pollset *pollset) { static void multipoll_with_epoll_pollset_destroy(grpc_pollset *pollset) {
pollset_hdr *h = pollset->data.ptr; pollset_hdr *h = pollset->data.ptr;
@ -158,9 +159,12 @@ static void epoll_kick(grpc_pollset *pollset) {
} }
static const grpc_pollset_vtable multipoll_with_epoll_pollset = { static const grpc_pollset_vtable multipoll_with_epoll_pollset = {
multipoll_with_epoll_pollset_add_fd, multipoll_with_epoll_pollset_del_fd, multipoll_with_epoll_pollset_add_fd,
multipoll_with_epoll_pollset_maybe_work, epoll_kick, multipoll_with_epoll_pollset_del_fd,
multipoll_with_epoll_pollset_finish_shutdown, multipoll_with_epoll_pollset_destroy}; multipoll_with_epoll_pollset_maybe_work,
epoll_kick,
multipoll_with_epoll_pollset_finish_shutdown,
multipoll_with_epoll_pollset_destroy};
static void epoll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds, static void epoll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
size_t nfds) { size_t nfds) {

@ -231,9 +231,12 @@ static void multipoll_with_poll_pollset_destroy(grpc_pollset *pollset) {
} }
static const grpc_pollset_vtable multipoll_with_poll_pollset = { static const grpc_pollset_vtable multipoll_with_poll_pollset = {
multipoll_with_poll_pollset_add_fd, multipoll_with_poll_pollset_del_fd, multipoll_with_poll_pollset_add_fd,
multipoll_with_poll_pollset_maybe_work, multipoll_with_poll_pollset_kick, multipoll_with_poll_pollset_del_fd,
multipoll_with_poll_pollset_finish_shutdown, multipoll_with_poll_pollset_destroy}; multipoll_with_poll_pollset_maybe_work,
multipoll_with_poll_pollset_kick,
multipoll_with_poll_pollset_finish_shutdown,
multipoll_with_poll_pollset_destroy};
void grpc_poll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds, void grpc_poll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
size_t nfds) { size_t nfds) {

@ -417,7 +417,7 @@ static void basic_pollset_destroy(grpc_pollset *pollset) {
} }
static const grpc_pollset_vtable basic_pollset = { static const grpc_pollset_vtable basic_pollset = {
basic_pollset_add_fd, basic_pollset_del_fd, basic_pollset_maybe_work, basic_pollset_add_fd, basic_pollset_del_fd, basic_pollset_maybe_work,
kick_using_pollset_kick, basic_pollset_destroy, basic_pollset_destroy}; kick_using_pollset_kick, basic_pollset_destroy, basic_pollset_destroy};
static void become_basic_pollset(grpc_pollset *pollset, grpc_fd *fd_or_null) { static void become_basic_pollset(grpc_pollset *pollset, grpc_fd *fd_or_null) {

@ -34,8 +34,6 @@
#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H #ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H #define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
typedef struct grpc_pollset_set { typedef struct grpc_pollset_set { void *unused; } grpc_pollset_set;
void *unused;
} grpc_pollset_set;
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */

@ -46,9 +46,7 @@
set of features for the sake of the rest of grpc. But grpc_pollset_work set of features for the sake of the rest of grpc. But grpc_pollset_work
won't actually do any polling, and return as quickly as possible. */ won't actually do any polling, and return as quickly as possible. */
void grpc_pollset_init(grpc_pollset *pollset) { void grpc_pollset_init(grpc_pollset *pollset) { gpr_mu_init(&pollset->mu); }
gpr_mu_init(&pollset->mu);
}
void grpc_pollset_shutdown(grpc_pollset *pollset, void grpc_pollset_shutdown(grpc_pollset *pollset,
void (*shutdown_done)(void *arg), void (*shutdown_done)(void *arg),
@ -75,6 +73,6 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
return 0 /* GPR_FALSE */; return 0 /* GPR_FALSE */;
} }
void grpc_pollset_kick(grpc_pollset *p) { } void grpc_pollset_kick(grpc_pollset *p) {}
#endif /* GPR_WINSOCK_SOCKET */ #endif /* GPR_WINSOCK_SOCKET */

@ -45,10 +45,8 @@
and a condition variable, as this is the minimal set of features we need and a condition variable, as this is the minimal set of features we need
implemented for the rest of grpc. But we won't use them directly. */ implemented for the rest of grpc. But we won't use them directly. */
typedef struct grpc_pollset { typedef struct grpc_pollset { gpr_mu mu; } grpc_pollset;
gpr_mu mu;
} grpc_pollset;
#define GRPC_POLLSET_MU(pollset) (&(pollset)->mu) #define GRPC_POLLSET_MU(pollset) (&(pollset)->mu)
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */

@ -135,9 +135,9 @@ static void do_request(void *rp) {
grpc_resolve_cb cb = r->cb; grpc_resolve_cb cb = r->cb;
gpr_free(r->name); gpr_free(r->name);
gpr_free(r->default_port); gpr_free(r->default_port);
grpc_iomgr_unregister_object(&r->iomgr_object);
gpr_free(r); gpr_free(r);
cb(arg, resolved); cb(arg, resolved);
grpc_iomgr_unregister_object(&r->iomgr_object);
} }
void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) {

@ -85,13 +85,13 @@ int grpc_winsocket_shutdown(grpc_winsocket *socket) {
both memory and sockets. */ both memory and sockets. */
void grpc_winsocket_orphan(grpc_winsocket *winsocket) { void grpc_winsocket_orphan(grpc_winsocket *winsocket) {
SOCKET socket = winsocket->socket; SOCKET socket = winsocket->socket;
grpc_iomgr_unregister_object(&winsocket->iomgr_object);
if (winsocket->read_info.outstanding || winsocket->write_info.outstanding) { if (winsocket->read_info.outstanding || winsocket->write_info.outstanding) {
grpc_iocp_socket_orphan(winsocket); grpc_iocp_socket_orphan(winsocket);
} else { } else {
grpc_winsocket_destroy(winsocket); grpc_winsocket_destroy(winsocket);
} }
closesocket(socket); closesocket(socket);
grpc_iomgr_unregister_object(&winsocket->iomgr_object);
} }
void grpc_winsocket_destroy(grpc_winsocket *winsocket) { void grpc_winsocket_destroy(grpc_winsocket *winsocket) {

@ -47,4 +47,4 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
const struct sockaddr *addr, int addr_len, const struct sockaddr *addr, int addr_len,
gpr_timespec deadline); gpr_timespec deadline);
#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H */

@ -223,8 +223,7 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep),
fdobj = grpc_fd_create(fd, name); fdobj = grpc_fd_create(fd, name);
if (err >= 0) { if (err >= 0) {
cb(arg, cb(arg, grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
goto done; goto done;
} }

@ -52,7 +52,7 @@
#include "src/core/iomgr/socket_windows.h" #include "src/core/iomgr/socket_windows.h"
typedef struct { typedef struct {
void(*cb)(void *arg, grpc_endpoint *tcp); void (*cb)(void *arg, grpc_endpoint *tcp);
void *cb_arg; void *cb_arg;
gpr_mu mu; gpr_mu mu;
grpc_winsocket *socket; grpc_winsocket *socket;
@ -86,7 +86,7 @@ static void on_connect(void *acp, int from_iocp) {
SOCKET sock = ac->socket->socket; SOCKET sock = ac->socket->socket;
grpc_endpoint *ep = NULL; grpc_endpoint *ep = NULL;
grpc_winsocket_callback_info *info = &ac->socket->write_info; grpc_winsocket_callback_info *info = &ac->socket->write_info;
void(*cb)(void *arg, grpc_endpoint *tcp) = ac->cb; void (*cb)(void *arg, grpc_endpoint *tcp) = ac->cb;
void *cb_arg = ac->cb_arg; void *cb_arg = ac->cb_arg;
int aborted; int aborted;
@ -99,8 +99,7 @@ static void on_connect(void *acp, int from_iocp) {
DWORD transfered_bytes = 0; DWORD transfered_bytes = 0;
DWORD flags; DWORD flags;
BOOL wsa_success = WSAGetOverlappedResult(sock, &info->overlapped, BOOL wsa_success = WSAGetOverlappedResult(sock, &info->overlapped,
&transfered_bytes, FALSE, &transfered_bytes, FALSE, &flags);
&flags);
info->outstanding = 0; info->outstanding = 0;
GPR_ASSERT(transfered_bytes == 0); GPR_ASSERT(transfered_bytes == 0);
if (!wsa_success) { if (!wsa_success) {
@ -176,9 +175,9 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
/* Grab the function pointer for ConnectEx for that specific socket. /* Grab the function pointer for ConnectEx for that specific socket.
It may change depending on the interface. */ It may change depending on the interface. */
status = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, status =
&guid, sizeof(guid), &ConnectEx, sizeof(ConnectEx), WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid),
&ioctl_num_bytes, NULL, NULL); &ConnectEx, sizeof(ConnectEx), &ioctl_num_bytes, NULL, NULL);
if (status != 0) { if (status != 0) {
message = "Unable to retrieve ConnectEx pointer: %s"; message = "Unable to retrieve ConnectEx pointer: %s";
@ -187,8 +186,7 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
grpc_sockaddr_make_wildcard6(0, &local_address); grpc_sockaddr_make_wildcard6(0, &local_address);
status = bind(sock, (struct sockaddr *) &local_address, status = bind(sock, (struct sockaddr *)&local_address, sizeof(local_address));
sizeof(local_address));
if (status != 0) { if (status != 0) {
message = "Unable to bind socket: %s"; message = "Unable to bind socket: %s";
goto failure; goto failure;
@ -234,4 +232,4 @@ failure:
cb(arg, NULL); cb(arg, NULL);
} }
#endif /* GPR_WINSOCK_SOCKET */ #endif /* GPR_WINSOCK_SOCKET */

@ -266,7 +266,7 @@ typedef struct {
grpc_endpoint base; grpc_endpoint base;
grpc_fd *em_fd; grpc_fd *em_fd;
int fd; int fd;
int iov_size; /* Number of slices to allocate per read attempt */ int iov_size; /* Number of slices to allocate per read attempt */
int finished_edge; int finished_edge;
size_t slice_size; size_t slice_size;
gpr_refcount refcount; gpr_refcount refcount;
@ -412,8 +412,7 @@ static void grpc_tcp_continue_read(grpc_tcp *tcp) {
++tcp->iov_size; ++tcp->iov_size;
} }
GPR_ASSERT(slice_state_has_available(&read_state)); GPR_ASSERT(slice_state_has_available(&read_state));
slice_state_transfer_ownership(&read_state, &final_slices, slice_state_transfer_ownership(&read_state, &final_slices, &final_nslices);
&final_nslices);
call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_OK); call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_OK);
slice_state_destroy(&read_state); slice_state_destroy(&read_state);
grpc_tcp_unref(tcp); grpc_tcp_unref(tcp);

@ -336,9 +336,8 @@ static void on_read(void *arg, int success) {
for (i = 0; i < sp->server->pollset_count; i++) { for (i = 0; i < sp->server->pollset_count; i++) {
grpc_pollset_add_fd(sp->server->pollsets[i], fdobj); grpc_pollset_add_fd(sp->server->pollsets[i], fdobj);
} }
sp->server->cb( sp->server->cb(sp->server->cb_arg,
sp->server->cb_arg, grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
gpr_free(name); gpr_free(name);
gpr_free(addr_str); gpr_free(addr_str);

@ -303,13 +303,10 @@ static void init_channel_elem(grpc_channel_element *elem,
chand->security_connector = chand->security_connector =
(grpc_channel_security_connector *)grpc_security_connector_ref(sc); (grpc_channel_security_connector *)grpc_security_connector_ref(sc);
chand->md_ctx = metadata_context; chand->md_ctx = metadata_context;
chand->authority_string = chand->authority_string = grpc_mdstr_from_string(chand->md_ctx, ":authority");
grpc_mdstr_from_string(chand->md_ctx, ":authority");
chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path"); chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path");
chand->error_msg_key = chand->error_msg_key = grpc_mdstr_from_string(chand->md_ctx, "grpc-message");
grpc_mdstr_from_string(chand->md_ctx, "grpc-message"); chand->status_key = grpc_mdstr_from_string(chand->md_ctx, "grpc-status");
chand->status_key =
grpc_mdstr_from_string(chand->md_ctx, "grpc-status");
} }
/* Destructor for channel data */ /* Destructor for channel data */
@ -333,6 +330,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_client_auth_filter = { const grpc_channel_filter grpc_client_auth_filter = {
auth_start_transport_op, channel_op, sizeof(call_data), init_call_elem, auth_start_transport_op, channel_op, sizeof(call_data),
destroy_call_elem, sizeof(channel_data), init_channel_elem, init_call_elem, destroy_call_elem, sizeof(channel_data),
destroy_channel_elem, "client-auth"}; init_channel_elem, destroy_channel_elem, "client-auth"};

@ -486,8 +486,8 @@ static int oauth2_token_fetcher_has_request_metadata_only(
grpc_credentials_status grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response( grpc_oauth2_token_fetcher_credentials_parse_server_response(
const grpc_httpcli_response *response, const grpc_httpcli_response *response, grpc_credentials_md_store **token_md,
grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime) { gpr_timespec *token_lifetime) {
char *null_terminated_body = NULL; char *null_terminated_body = NULL;
char *new_access_token = NULL; char *new_access_token = NULL;
grpc_credentials_status status = GRPC_CREDENTIALS_OK; grpc_credentials_status status = GRPC_CREDENTIALS_OK;
@ -610,7 +610,8 @@ static void oauth2_token_fetcher_get_request_metadata(
if (c->access_token_md != NULL && if (c->access_token_md != NULL &&
(gpr_time_cmp(gpr_time_sub(c->token_expiration, gpr_now()), (gpr_time_cmp(gpr_time_sub(c->token_expiration, gpr_now()),
refresh_threshold) > 0)) { refresh_threshold) > 0)) {
cached_access_token_md = grpc_credentials_md_store_ref(c->access_token_md); cached_access_token_md =
grpc_credentials_md_store_ref(c->access_token_md);
} }
gpr_mu_unlock(&c->mu); gpr_mu_unlock(&c->mu);
} }
@ -640,8 +641,7 @@ static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c,
/* -- ComputeEngine credentials. -- */ /* -- ComputeEngine credentials. -- */
static grpc_credentials_vtable compute_engine_vtable = { static grpc_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_destroy, oauth2_token_fetcher_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only, oauth2_token_fetcher_has_request_metadata_only,
oauth2_token_fetcher_get_request_metadata, NULL}; oauth2_token_fetcher_get_request_metadata, NULL};
@ -686,8 +686,7 @@ static void service_account_destroy(grpc_credentials *creds) {
} }
static grpc_credentials_vtable service_account_vtable = { static grpc_credentials_vtable service_account_vtable = {
service_account_destroy, service_account_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only, oauth2_token_fetcher_has_request_metadata_only,
oauth2_token_fetcher_get_request_metadata, NULL}; oauth2_token_fetcher_get_request_metadata, NULL};
@ -760,8 +759,7 @@ static void refresh_token_destroy(grpc_credentials *creds) {
} }
static grpc_credentials_vtable refresh_token_vtable = { static grpc_credentials_vtable refresh_token_vtable = {
refresh_token_destroy, refresh_token_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only, oauth2_token_fetcher_has_request_metadata_only,
oauth2_token_fetcher_get_request_metadata, NULL}; oauth2_token_fetcher_get_request_metadata, NULL};
@ -900,8 +898,7 @@ static int fake_transport_security_has_request_metadata_only(
return 0; return 0;
} }
static grpc_security_status static grpc_security_status fake_transport_security_create_security_connector(
fake_transport_security_create_security_connector(
grpc_credentials *c, const char *target, const grpc_channel_args *args, grpc_credentials *c, const char *target, const grpc_channel_args *args,
grpc_credentials *request_metadata_creds, grpc_credentials *request_metadata_creds,
grpc_channel_security_connector **sc, grpc_channel_args **new_args) { grpc_channel_security_connector **sc, grpc_channel_args **new_args) {

@ -108,7 +108,6 @@ grpc_credentials_md_store *grpc_credentials_md_store_ref(
grpc_credentials_md_store *store); grpc_credentials_md_store *store);
void grpc_credentials_md_store_unref(grpc_credentials_md_store *store); void grpc_credentials_md_store_unref(grpc_credentials_md_store *store);
/* --- grpc_credentials. --- */ /* --- grpc_credentials. --- */
/* It is the caller's responsibility to gpr_free the result if not NULL. */ /* It is the caller's responsibility to gpr_free the result if not NULL. */
@ -177,8 +176,8 @@ grpc_credentials *grpc_credentials_contains_type(
/* Exposed for testing only. */ /* Exposed for testing only. */
grpc_credentials_status grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response( grpc_oauth2_token_fetcher_credentials_parse_server_response(
const struct grpc_httpcli_response *response, grpc_credentials_md_store **token_md, const struct grpc_httpcli_response *response,
gpr_timespec *token_lifetime); grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime);
/* Simulates an oauth2 token fetch with the specified value for testing. */ /* Simulates an oauth2 token fetch with the specified value for testing. */
grpc_credentials *grpc_fake_oauth2_credentials_create( grpc_credentials *grpc_fake_oauth2_credentials_create(

@ -55,9 +55,7 @@ static int compute_engine_detection_done = 0;
static gpr_mu g_mu; static gpr_mu g_mu;
static gpr_once g_once = GPR_ONCE_INIT; static gpr_once g_once = GPR_ONCE_INIT;
static void init_default_credentials(void) { static void init_default_credentials(void) { gpr_mu_init(&g_mu); }
gpr_mu_init(&g_mu);
}
typedef struct { typedef struct {
grpc_pollset pollset; grpc_pollset pollset;

@ -200,7 +200,7 @@ static void destroy_channel(void *p, int ok) {
#ifdef GRPC_CHANNEL_REF_COUNT_DEBUG #ifdef GRPC_CHANNEL_REF_COUNT_DEBUG
void grpc_channel_internal_unref(grpc_channel *channel, const char *reason) { void grpc_channel_internal_unref(grpc_channel *channel, const char *reason) {
gpr_log(GPR_DEBUG, "CHANNEL: unref %p %d -> %d [%s]", channel, gpr_log(GPR_DEBUG, "CHANNEL: unref %p %d -> %d [%s]", channel,
channel->refs.count, channel->refs.count - 1, reason); channel->refs.count, channel->refs.count - 1, reason);
#else #else
void grpc_channel_internal_unref(grpc_channel *channel) { void grpc_channel_internal_unref(grpc_channel *channel) {

@ -138,7 +138,8 @@ static void on_resolved(void *rp, grpc_resolved_addresses *resolved) {
request *r = rp; request *r = rp;
/* if we're not still the active request, abort */ /* if we're not still the active request, abort */
if (!grpc_client_setup_request_should_continue(r->cs_request, "on_resolved")) { if (!grpc_client_setup_request_should_continue(r->cs_request,
"on_resolved")) {
if (resolved) { if (resolved) {
grpc_resolved_addresses_destroy(resolved); grpc_resolved_addresses_destroy(resolved);
} }

@ -86,21 +86,10 @@ grpc_completion_queue *grpc_completion_queue_create(void) {
return cc; return cc;
} }
#ifdef GRPC_CQ_REF_COUNT_DEBUG #ifdef GRPC_CQ_REF_COUNT_DEBUG
void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason) { void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason) {
gpr_log(GPR_DEBUG, "CQ:%p ref %d -> %d %s", cc, (int)cc->owning_refs.count, (int)cc->owning_refs.count + 1, reason); gpr_log(GPR_DEBUG, "CQ:%p ref %d -> %d %s", cc, (int)cc->owning_refs.count,
(int)cc->owning_refs.count + 1, reason);
#else #else
void grpc_cq_internal_ref(grpc_completion_queue *cc) { void grpc_cq_internal_ref(grpc_completion_queue *cc) {
#endif #endif
@ -114,7 +103,8 @@ static void on_pollset_destroy_done(void *arg) {
#ifdef GRPC_CQ_REF_COUNT_DEBUG #ifdef GRPC_CQ_REF_COUNT_DEBUG
void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason) { void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason) {
gpr_log(GPR_DEBUG, "CQ:%p unref %d -> %d %s", cc, (int)cc->owning_refs.count, (int)cc->owning_refs.count - 1, reason); gpr_log(GPR_DEBUG, "CQ:%p unref %d -> %d %s", cc, (int)cc->owning_refs.count,
(int)cc->owning_refs.count - 1, reason);
#else #else
void grpc_cq_internal_unref(grpc_completion_queue *cc) { void grpc_cq_internal_unref(grpc_completion_queue *cc) {
#endif #endif

@ -78,6 +78,7 @@ void grpc_shutdown(void) {
grpc_iomgr_shutdown(); grpc_iomgr_shutdown();
census_shutdown(); census_shutdown();
grpc_timers_global_destroy(); grpc_timers_global_destroy();
grpc_tracer_shutdown();
} }
gpr_mu_unlock(&g_init_mu); gpr_mu_unlock(&g_init_mu);
} }

@ -118,9 +118,9 @@ static void init_channel_elem(grpc_channel_element *elem,
static void destroy_channel_elem(grpc_channel_element *elem) {} static void destroy_channel_elem(grpc_channel_element *elem) {}
static const grpc_channel_filter lame_filter = { static const grpc_channel_filter lame_filter = {
lame_start_transport_op, channel_op, sizeof(call_data), init_call_elem, lame_start_transport_op, channel_op, sizeof(call_data),
destroy_call_elem, sizeof(channel_data), init_channel_elem, init_call_elem, destroy_call_elem, sizeof(channel_data),
destroy_channel_elem, "lame-client", init_channel_elem, destroy_channel_elem, "lame-client",
}; };
grpc_channel *grpc_lame_client_channel_create(void) { grpc_channel *grpc_lame_client_channel_create(void) {

@ -97,7 +97,8 @@ static void on_secure_transport_setup_done(void *rp,
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status); gpr_log(GPR_ERROR, "Secure transport setup failed with error %d.", status);
done(r, 0); done(r, 0);
} else if (grpc_client_setup_cb_begin(r->cs_request, "on_secure_transport_setup_done")) { } else if (grpc_client_setup_cb_begin(r->cs_request,
"on_secure_transport_setup_done")) {
grpc_create_chttp2_transport( grpc_create_chttp2_transport(
r->setup->setup_callback, r->setup->setup_user_data, r->setup->setup_callback, r->setup->setup_user_data,
grpc_client_setup_get_channel_args(r->cs_request), secure_endpoint, grpc_client_setup_get_channel_args(r->cs_request), secure_endpoint,
@ -113,7 +114,8 @@ static void on_secure_transport_setup_done(void *rp,
static void on_connect(void *rp, grpc_endpoint *tcp) { static void on_connect(void *rp, grpc_endpoint *tcp) {
request *r = rp; request *r = rp;
if (!grpc_client_setup_request_should_continue(r->cs_request, "on_connect.secure")) { if (!grpc_client_setup_request_should_continue(r->cs_request,
"on_connect.secure")) {
if (tcp) { if (tcp) {
grpc_endpoint_shutdown(tcp); grpc_endpoint_shutdown(tcp);
grpc_endpoint_destroy(tcp); grpc_endpoint_destroy(tcp);
@ -153,7 +155,8 @@ static void on_resolved(void *rp, grpc_resolved_addresses *resolved) {
request *r = rp; request *r = rp;
/* if we're not still the active request, abort */ /* if we're not still the active request, abort */
if (!grpc_client_setup_request_should_continue(r->cs_request, "on_resolved.secure")) { if (!grpc_client_setup_request_should_continue(r->cs_request,
"on_resolved.secure")) {
if (resolved) { if (resolved) {
grpc_resolved_addresses_destroy(resolved); grpc_resolved_addresses_destroy(resolved);
} }

@ -495,7 +495,6 @@ static void server_on_recv(void *ptr, int success) {
calld->state = ZOMBIED; calld->state = ZOMBIED;
grpc_iomgr_closure_init(&calld->kill_zombie_closure, kill_zombie, elem); grpc_iomgr_closure_init(&calld->kill_zombie_closure, kill_zombie, elem);
grpc_iomgr_add_callback(&calld->kill_zombie_closure); grpc_iomgr_add_callback(&calld->kill_zombie_closure);
} }
if (call_list_remove(calld, ALL_CALLS)) { if (call_list_remove(calld, ALL_CALLS)) {
decrement_call_count(chand); decrement_call_count(chand);
@ -591,7 +590,8 @@ static void finish_shutdown_channel(void *p, int success) {
gpr_free(sca); gpr_free(sca);
} }
static void shutdown_channel(channel_data *chand, int send_goaway, int send_disconnect) { static void shutdown_channel(channel_data *chand, int send_goaway,
int send_disconnect) {
shutdown_channel_args *sca; shutdown_channel_args *sca;
GRPC_CHANNEL_INTERNAL_REF(chand->channel, "shutdown"); GRPC_CHANNEL_INTERNAL_REF(chand->channel, "shutdown");
sca = gpr_malloc(sizeof(shutdown_channel_args)); sca = gpr_malloc(sizeof(shutdown_channel_args));

@ -998,10 +998,12 @@ static void finalize_outbuf(transport *t) {
while ((s = stream_list_remove_head(t, WRITING))) { while ((s = stream_list_remove_head(t, WRITING))) {
grpc_chttp2_encode(s->writing_sopb.ops, s->writing_sopb.nops, grpc_chttp2_encode(s->writing_sopb.ops, s->writing_sopb.nops,
s->send_closed != DONT_SEND_CLOSED, s->id, &t->hpack_compressor, &t->outbuf); s->send_closed != DONT_SEND_CLOSED, s->id,
&t->hpack_compressor, &t->outbuf);
s->writing_sopb.nops = 0; s->writing_sopb.nops = 0;
if (s->send_closed == SEND_CLOSED_WITH_RST_STREAM) { if (s->send_closed == SEND_CLOSED_WITH_RST_STREAM) {
gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_CHTTP2_NO_ERROR)); gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create(
s->id, GRPC_CHTTP2_NO_ERROR));
} }
if (s->send_closed != DONT_SEND_CLOSED) { if (s->send_closed != DONT_SEND_CLOSED) {
stream_list_join(t, s, WRITTEN_CLOSED); stream_list_join(t, s, WRITTEN_CLOSED);
@ -1064,12 +1066,12 @@ static void perform_write(transport *t, grpc_endpoint *ep) {
} }
} }
static void add_goaway(transport *t, gpr_uint32 goaway_error, gpr_slice goaway_text) { static void add_goaway(transport *t, gpr_uint32 goaway_error,
gpr_slice goaway_text) {
if (t->num_pending_goaways == t->cap_pending_goaways) { if (t->num_pending_goaways == t->cap_pending_goaways) {
t->cap_pending_goaways = GPR_MAX(1, t->cap_pending_goaways * 2); t->cap_pending_goaways = GPR_MAX(1, t->cap_pending_goaways * 2);
t->pending_goaways = t->pending_goaways = gpr_realloc(
gpr_realloc(t->pending_goaways, t->pending_goaways, sizeof(pending_goaway) * t->cap_pending_goaways);
sizeof(pending_goaway) * t->cap_pending_goaways);
} }
t->pending_goaways[t->num_pending_goaways].status = t->pending_goaways[t->num_pending_goaways].status =
grpc_chttp2_http2_error_to_grpc_status(goaway_error); grpc_chttp2_http2_error_to_grpc_status(goaway_error);
@ -1077,13 +1079,12 @@ static void add_goaway(transport *t, gpr_uint32 goaway_error, gpr_slice goaway_t
t->num_pending_goaways++; t->num_pending_goaways++;
} }
static void maybe_start_some_streams(transport *t) { static void maybe_start_some_streams(transport *t) {
/* start streams where we have free stream ids and free concurrency */ /* start streams where we have free stream ids and free concurrency */
while ( while (t->next_stream_id <= MAX_CLIENT_STREAM_ID &&
t->next_stream_id <= MAX_CLIENT_STREAM_ID && grpc_chttp2_stream_map_size(&t->stream_map) <
grpc_chttp2_stream_map_size(&t->stream_map) < t->settings[PEER_SETTINGS]
t->settings[PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]) { [GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]) {
stream *s = stream_list_remove_head(t, WAITING_FOR_CONCURRENCY); stream *s = stream_list_remove_head(t, WAITING_FOR_CONCURRENCY);
if (!s) return; if (!s) return;
@ -1091,7 +1092,9 @@ static void maybe_start_some_streams(transport *t) {
t->is_client ? "CLI" : "SVR", s, t->next_stream_id)); t->is_client ? "CLI" : "SVR", s, t->next_stream_id));
if (t->next_stream_id == MAX_CLIENT_STREAM_ID) { if (t->next_stream_id == MAX_CLIENT_STREAM_ID) {
add_goaway(t, GRPC_CHTTP2_NO_ERROR, gpr_slice_from_copied_string("Exceeded sequence number limit")); add_goaway(
t, GRPC_CHTTP2_NO_ERROR,
gpr_slice_from_copied_string("Exceeded sequence number limit"));
} }
GPR_ASSERT(s->id == 0); GPR_ASSERT(s->id == 0);
@ -1109,7 +1112,10 @@ static void maybe_start_some_streams(transport *t) {
stream *s = stream_list_remove_head(t, WAITING_FOR_CONCURRENCY); stream *s = stream_list_remove_head(t, WAITING_FOR_CONCURRENCY);
if (!s) return; if (!s) return;
cancel_stream(t, s, GRPC_STATUS_UNAVAILABLE, grpc_chttp2_grpc_status_to_http2_error(GRPC_STATUS_UNAVAILABLE), NULL, 0); cancel_stream(
t, s, GRPC_STATUS_UNAVAILABLE,
grpc_chttp2_grpc_status_to_http2_error(GRPC_STATUS_UNAVAILABLE), NULL,
0);
} }
} }
@ -1167,7 +1173,7 @@ static void perform_op_locked(transport *t, stream *s, grpc_transport_op *op) {
op_closure c; op_closure c;
c.cb = op->on_consumed; c.cb = op->on_consumed;
c.user_data = op->on_consumed_user_data; c.user_data = op->on_consumed_user_data;
schedule_cb(t, c, 1); schedule_cb(t, c, 1);
} }
} }
@ -1262,8 +1268,8 @@ static void cancel_stream_inner(transport *t, stream *s, gpr_uint32 id,
/* synthesize a status if we don't believe we'll get one */ /* synthesize a status if we don't believe we'll get one */
gpr_ltoa(local_status, buffer); gpr_ltoa(local_status, buffer);
add_incoming_metadata( add_incoming_metadata(
t, s, t, s, grpc_mdelem_from_strings(t->metadata_context, "grpc-status",
grpc_mdelem_from_strings(t->metadata_context, "grpc-status", buffer)); buffer));
if (!optional_message) { if (!optional_message) {
switch (local_status) { switch (local_status) {
case GRPC_STATUS_CANCELLED: case GRPC_STATUS_CANCELLED:
@ -1502,7 +1508,8 @@ static int init_header_frame_parser(transport *t, int is_continuation) {
t->last_incoming_stream_id, t->incoming_stream_id); t->last_incoming_stream_id, t->incoming_stream_id);
return init_skip_frame(t, 1); return init_skip_frame(t, 1);
} else if ((t->incoming_stream_id & 1) == 0) { } else if ((t->incoming_stream_id & 1) == 0) {
gpr_log(GPR_ERROR, "ignoring stream with non-client generated index %d", t->incoming_stream_id); gpr_log(GPR_ERROR, "ignoring stream with non-client generated index %d",
t->incoming_stream_id);
return init_skip_frame(t, 1); return init_skip_frame(t, 1);
} }
t->incoming_stream = NULL; t->incoming_stream = NULL;
@ -1562,10 +1569,10 @@ static int init_ping_parser(transport *t) {
} }
static int init_rst_stream_parser(transport *t) { static int init_rst_stream_parser(transport *t) {
int ok = GRPC_CHTTP2_PARSE_OK == int ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_rst_stream_parser_begin_frame(
grpc_chttp2_rst_stream_parser_begin_frame(&t->simple_parsers.rst_stream, &t->simple_parsers.rst_stream,
t->incoming_frame_size, t->incoming_frame_size,
t->incoming_frame_flags); t->incoming_frame_flags);
if (!ok) { if (!ok) {
drop_connection(t); drop_connection(t);
} }
@ -1655,7 +1662,7 @@ static void add_metadata_batch(transport *t, stream *s) {
we can reconstitute the list. we can reconstitute the list.
We can't do list building here as later incoming metadata may reallocate We can't do list building here as later incoming metadata may reallocate
the underlying array. */ the underlying array. */
b.list.tail = (void*)(gpr_intptr)s->incoming_metadata_count; b.list.tail = (void *)(gpr_intptr)s->incoming_metadata_count;
b.garbage.head = b.garbage.tail = NULL; b.garbage.head = b.garbage.tail = NULL;
b.deadline = s->incoming_deadline; b.deadline = s->incoming_deadline;
s->incoming_deadline = gpr_inf_future; s->incoming_deadline = gpr_inf_future;
@ -2013,7 +2020,7 @@ static void patch_metadata_ops(stream *s) {
int found_metadata = 0; int found_metadata = 0;
/* rework the array of metadata into a linked list, making use /* rework the array of metadata into a linked list, making use
of the breadcrumbs we left in metadata batches during of the breadcrumbs we left in metadata batches during
add_metadata_batch */ add_metadata_batch */
for (i = 0; i < nops; i++) { for (i = 0; i < nops; i++) {
grpc_stream_op *op = &ops[i]; grpc_stream_op *op = &ops[i];
@ -2029,11 +2036,11 @@ static void patch_metadata_ops(stream *s) {
op->data.metadata.list.head = &s->incoming_metadata[mdidx]; op->data.metadata.list.head = &s->incoming_metadata[mdidx];
op->data.metadata.list.tail = &s->incoming_metadata[last_mdidx - 1]; op->data.metadata.list.tail = &s->incoming_metadata[last_mdidx - 1];
for (j = mdidx + 1; j < last_mdidx; j++) { for (j = mdidx + 1; j < last_mdidx; j++) {
s->incoming_metadata[j].prev = &s->incoming_metadata[j-1]; s->incoming_metadata[j].prev = &s->incoming_metadata[j - 1];
s->incoming_metadata[j-1].next = &s->incoming_metadata[j]; s->incoming_metadata[j - 1].next = &s->incoming_metadata[j];
} }
s->incoming_metadata[mdidx].prev = NULL; s->incoming_metadata[mdidx].prev = NULL;
s->incoming_metadata[last_mdidx-1].next = NULL; s->incoming_metadata[last_mdidx - 1].next = NULL;
/* track where we're up to */ /* track where we're up to */
mdidx = last_mdidx; mdidx = last_mdidx;
} }
@ -2045,7 +2052,8 @@ static void patch_metadata_ops(stream *s) {
size_t copy_bytes = sizeof(*s->incoming_metadata) * new_count; size_t copy_bytes = sizeof(*s->incoming_metadata) * new_count;
GPR_ASSERT(mdidx < s->incoming_metadata_count); GPR_ASSERT(mdidx < s->incoming_metadata_count);
s->incoming_metadata = gpr_malloc(copy_bytes); s->incoming_metadata = gpr_malloc(copy_bytes);
memcpy(s->old_incoming_metadata + mdidx, s->incoming_metadata, copy_bytes); memcpy(s->old_incoming_metadata + mdidx, s->incoming_metadata,
copy_bytes);
s->incoming_metadata_count = s->incoming_metadata_capacity = new_count; s->incoming_metadata_count = s->incoming_metadata_capacity = new_count;
} else { } else {
s->incoming_metadata = NULL; s->incoming_metadata = NULL;
@ -2082,7 +2090,6 @@ static void finish_reads(transport *t) {
schedule_cb(t, s->recv_done_closure, 1); schedule_cb(t, s->recv_done_closure, 1);
} }
} }
} }
static void schedule_cb(transport *t, op_closure closure, int success) { static void schedule_cb(transport *t, op_closure closure, int success) {

@ -1,78 +1,89 @@
# gRPC for Objective-C # gRPC for Objective-C
- [Install protoc with the gRPC plugin](#install) - [Install protoc with the gRPC plugin](#install)
- [Use protoc to generate a gRPC library](#protoc) - [Write your API declaration in proto format](#write-protos)
- [Integrate the generated gRPC library in your project](#cocoapods) - [Integrate a proto library in your project](#cocoapods)
- [Use the generated library in your code](#use) - [Use the generated library in your code](#use)
- [Alternative methods](#alternatives) - [Use gRPC without Protobuf](#no-proto)
- [Install protoc and the gRPC plugin without using Homebrew](#nohomebrew) - [Alternative installation methods](#alternatives)
- [Integrate the generated gRPC library without using Cocoapods](#nococoapods) - [Install protoc and the gRPC plugin without using Homebrew](#no-homebrew)
- [Integrate the generated gRPC library without using Cocoapods](#no-cocoapods)
While gRPC doesn't require the use of an IDL to describe the API of services, using one simplifies
usage and adds some interoperability guarantees. Here we use [Protocol Buffers][], and provide a
plugin for the Protobuf Compiler (_protoc_) to generate client libraries to communicate with gRPC
services.
<a name="install"></a> <a name="install"></a>
## Install protoc with the gRPC plugin ## Install protoc with the gRPC plugin
On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][]. On Mac OS X, install [homebrew][]. On Linux, install [linuxbrew][].
Run the following command to install the Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin: Run the following command to install _protoc_ and the gRPC _protoc_ plugin:
```sh ```sh
$ curl -fsSL https://goo.gl/getgrpc | bash - $ curl -fsSL https://goo.gl/getgrpc | bash -
``` ```
This will download and run the [gRPC install script][]. After the command completes, you're ready to proceed. This will download and run the [gRPC install script][]. After the command completes, you're ready to
proceed.
<a name="protoc"></a>
## Use protoc to generate a gRPC library
Run _protoc_ with the following flags to generate the client library for your `.proto` files: <a name="write-protos"></a>
## Write your API declaration in proto format
```sh
protoc --objc_out=. --objcgrpc_out=. *.proto
```
This will generate a pair of `.pbobjc.h`/`.pbobjc.m` files for each `.proto` file, with the messages and enums defined in them. And a pair of `.pbrpc.h`/`.pbrpc.m` files for each `.proto` file with services defined. The latter contains the code to make remote calls to the specified API. For this you can consult the [Protocol Buffers][]' official documentation, or learn from a quick
example [here](https://github.com/grpc/grpc-common#defining-a-service).
<a name="cocoapods"></a> <a name="cocoapods"></a>
## Integrate the generated gRPC library in your project ## Integrate a proto library in your project
Install [Cocoapods](https://cocoapods.org/#install). Install [Cocoapods](https://cocoapods.org/#install).
You need to create a Podspec file for the generated library. You may simply copy the following example to the directory where the source files were generated, updating the name and other metadata of the Podspec as necessary: You need to create a Podspec file for your proto library. You may simply copy the following example
to the directory where your `.proto` files are located, updating the name, version and license as
necessary:
```ruby ```ruby
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = '<Podspec file name>' s.name = '<Podspec file name>'
s.version = '...' s.version = '0.0.1'
s.summary = 'Client library to make RPCs to <my proto API>'
s.homepage = '...'
s.license = '...' s.license = '...'
s.authors = { '<my name>' => '<my email>' }
s.ios.deployment_target = '6.0' s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8' s.osx.deployment_target = '10.8'
s.subspec 'Messages' do |ms| # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
ms.source_files = '*.pbobjc.{h,m}', '**/*.pbobjc.{h,m}' # You can run this command manually if you later change your protos and need to regenerate.
ms.header_mappings_dir = '.' s.prepare_command = "protoc --objc_out=. --objcgrpc_out=. *.proto **/*.proto"
# The --objc_out plugin generates a pair of .pbobjc.h/.pbobjc.m files for each .proto file.
s.subspec "Messages" do |ms|
ms.source_files = "*.pbobjc.{h,m}", "**/*.pbobjc.{h,m}"
ms.header_mappings_dir = "."
ms.requires_arc = false ms.requires_arc = false
ms.dependency 'Protobuf', '~> 3.0' ms.dependency "Protobuf", "~> 3.0.0-alpha-3"
end end
s.subspec 'Services' do |ss| # The --objcgrpc_out plugin generates a pair of .pbrpc.h/.pbrpc.m files for each .proto file with
ss.source_files = '*.pbrpc.{h,m}', '**/*.pbrpc.{h,m}' # a service defined.
ss.header_mappings_dir = '.' s.subspec "Services" do |ss|
ss.source_files = "*.pbrpc.{h,m}", "**/*.pbrpc.{h,m}"
ss.header_mappings_dir = "."
ss.requires_arc = true ss.requires_arc = true
ss.dependency 'gRPC', '~> 0.0' ss.dependency "gRPC", "~> 0.5"
ss.dependency '<Podspec file name>/Messages' ss.dependency "#{s.name}/Messages"
end end
end end
``` ```
The file should be named `<Podspec file name>.podspec`. You can refer to this [example Podspec][]. Once your library has a Podspec, Cocoapods can install it into any XCode project. For that, go into your project's directory and create a Podfile by running: The file should be named `<Podspec file name>.podspec`. Once your library has a Podspec, Cocoapods
can install it into any XCode project. For that, go into your project's directory and create a
Podfile by running:
```sh ```sh
pod init pod init
``` ```
Next add a line to your Podfile to refer to your library's Podspec. Use `:path` as described [here](https://guides.cocoapods.org/using/the-podfile.html#using-the-files-from-a-folder-local-to-the-machine): Next add a line to your Podfile to refer to your library's Podspec. Use `:path` as described
[here](https://guides.cocoapods.org/using/the-podfile.html#using-the-files-from-a-folder-local-to-the-machine):
```ruby ```ruby
pod '<Podspec file name>', :path => 'path/to/the/directory/of/your/podspec' pod '<Podspec file name>', :path => 'path/to/the/directory/of/your/podspec'
@ -91,15 +102,25 @@ pod install
Please check this [sample app][] for examples of how to use a generated gRPC library. Please check this [sample app][] for examples of how to use a generated gRPC library.
<a name="no-proto"></a>
## Use gRPC without Protobuf
The [sample app][] has an example of how to use the generic gRPC Objective-C client without
generated files.
<a name="alternatives"></a> <a name="alternatives"></a>
## Alternative methods ## Alternative installation methods
<a name="nohomebrew"></a> <a name="no-homebrew"></a>
### Install protoc and the gRPC plugin without using Homebrew ### Install protoc and the gRPC plugin without using Homebrew
First install v3 of the Protocol Buffers compiler (_protoc_), by cloning [its Git repository](https://github.com/google/protobuf) and following these [installation instructions](https://github.com/google/protobuf#c-installation---unix) (the ones titled C++; don't miss the note for Mac users). First install v3 of the Protocol Buffers compiler (_protoc_), by cloning
[its Git repository](https://github.com/google/protobuf) and following these
[installation instructions](https://github.com/google/protobuf#c-installation---unix)
(the ones titled C++; don't miss the note for Mac users).
Then clone this repository and execute the following commands from the root directory where it was cloned. Then clone this repository and execute the following commands from the root directory where it was
cloned.
Compile the gRPC plugins for _protoc_: Compile the gRPC plugins for _protoc_:
```sh ```sh
@ -110,23 +131,32 @@ Create a symbolic link to the compiled plugin binary somewhere in your `$PATH`:
```sh ```sh
ln -s `pwd`/bins/opt/grpc_objective_c_plugin /usr/local/bin/protoc-gen-objcgrpc ln -s `pwd`/bins/opt/grpc_objective_c_plugin /usr/local/bin/protoc-gen-objcgrpc
``` ```
(Notice that the name of the created link must begin with "protoc-gen-" for _protoc_ to recognize it as a plugin). (Notice that the name of the created link must begin with "protoc-gen-" for _protoc_ to recognize it
as a plugin).
If you don't want to create the symbolic link, you can alternatively copy the binary (with the appropriate name). Or you might prefer instead to specify the plugin's path as a flag when invoking _protoc_, in which case no system modification nor renaming is necessary. If you don't want to create the symbolic link, you can alternatively copy the binary (with the
appropriate name). Or you might prefer instead to specify the plugin's path as a flag when invoking
_protoc_, in which case no system modification nor renaming is necessary.
<a name="nococoapods"></a> <a name="no-cocoapods"></a>
### Integrate the generated gRPC library without using Cocoapods ### Integrate the generated gRPC library without using Cocoapods
You need to compile the generated `.pbpbjc.*` files (the enums and messages) without ARC support, and the generated `.pbrpc.*` files (the services) with ARC support. The generated code depends on v0.3+ of the Objective-C gRPC runtime library and v3.0+ of the Objective-C Protobuf runtime library. You need to compile the generated `.pbpbjc.*` files (the enums and messages) without ARC support,
and the generated `.pbrpc.*` files (the services) with ARC support. The generated code depends on
v0.5+ of the Objective-C gRPC runtime library and v3.0.0-alpha-3+ of the Objective-C Protobuf
runtime library.
These libraries need to be integrated into your project as described in their respective Podspec files: These libraries need to be integrated into your project as described in their respective Podspec
files:
* [Podspec](https://github.com/grpc/grpc/blob/master/gRPC.podspec) for the Objective-C gRPC runtime library. This can be tedious to configure manually. * [Podspec](https://github.com/grpc/grpc/blob/master/gRPC.podspec) for the Objective-C gRPC runtime
* [Podspec](https://github.com/jcanizales/protobuf/blob/add-podspec/Protobuf.podspec) for the Objective-C Protobuf runtime library. library. This can be tedious to configure manually.
* [Podspec](https://github.com/jcanizales/protobuf/blob/add-podspec/Protobuf.podspec) for the
Objective-C Protobuf runtime library.
[Protocol Buffers]:https://developers.google.com/protocol-buffers/
[homebrew]:http://brew.sh [homebrew]:http://brew.sh
[linuxbrew]:https://github.com/Homebrew/linuxbrew [linuxbrew]:https://github.com/Homebrew/linuxbrew
[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install [gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
[example Podspec]:https://github.com/grpc/grpc/blob/master/src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec
[example Podfile]:https://github.com/grpc/grpc/blob/master/src/objective-c/examples/Sample/Podfile [example Podfile]:https://github.com/grpc/grpc/blob/master/src/objective-c/examples/Sample/Podfile
[sample app]: https://github.com/grpc/grpc/tree/master/src/objective-c/examples/Sample [sample app]: https://github.com/grpc/grpc/tree/master/src/objective-c/examples/Sample

@ -2,7 +2,6 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0' platform :ios, '8.0'
pod 'gRPC', :path => "../../../.." pod 'gRPC', :path => "../../../.."
pod 'Protobuf', :git => 'https://github.com/google/protobuf.git'
pod 'RemoteTest', :path => "../../generated_libraries/RemoteTestClient" pod 'RemoteTest', :path => "../../generated_libraries/RemoteTestClient"
target 'Sample' do target 'Sample' do

@ -1,33 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: empty.proto
#import "GPBProtocolBuffers.h"
#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
#error This file was generated by a different version of protoc-gen-objc which is incompatible with your Protocol Buffer sources.
#endif
CF_EXTERN_C_BEGIN
@class RMTEmpty;
#pragma mark - RMTEmptyRoot
@interface RMTEmptyRoot : GPBRootObject
@end
#pragma mark - RMTEmpty
// An empty message that you can re-use to avoid defining duplicated empty
// messages in your project. A typical example is to use it as argument or the
// return value of a service API. For instance:
//
// service Foo {
// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
// };
@interface RMTEmpty : GPBMessage
@end
CF_EXTERN_C_END

@ -1,59 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: empty.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
#import "Empty.pbobjc.h"
#pragma mark - RMTEmptyRoot
@implementation RMTEmptyRoot
@end
static GPBFileDescriptor *RMTEmptyRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"grpc.testing"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - RMTEmpty
@implementation RMTEmpty
typedef struct RMTEmpty_Storage {
uint32_t _has_storage_[0];
} RMTEmpty_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTEmpty class]
rootClass:[RMTEmptyRoot class]
file:RMTEmptyRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTEmpty_Storage)
wireFormat:NO];
}
return descriptor;
}
@end

@ -1,221 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: messages.proto
#import "GPBProtocolBuffers.h"
#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
#error This file was generated by a different version of protoc-gen-objc which is incompatible with your Protocol Buffer sources.
#endif
CF_EXTERN_C_BEGIN
@class RMTPayload;
@class RMTResponseParameters;
@class RMTSimpleRequest;
@class RMTSimpleResponse;
@class RMTStreamingInputCallRequest;
@class RMTStreamingInputCallResponse;
@class RMTStreamingOutputCallRequest;
@class RMTStreamingOutputCallResponse;
#pragma mark - Enum RMTPayloadType
// The type of payload that should be returned.
typedef GPB_ENUM(RMTPayloadType) {
RMTPayloadType_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
// Compressable text format.
RMTPayloadType_Compressable = 0,
// Uncompressable binary format.
RMTPayloadType_Uncompressable = 1,
// Randomly chosen from all other formats defined in this enum.
RMTPayloadType_Random = 2,
};
GPBEnumDescriptor *RMTPayloadType_EnumDescriptor(void);
BOOL RMTPayloadType_IsValidValue(int32_t value);
#pragma mark - RMTMessagesRoot
@interface RMTMessagesRoot : GPBRootObject
@end
#pragma mark - RMTPayload
typedef GPB_ENUM(RMTPayload_FieldNumber) {
RMTPayload_FieldNumber_Type = 1,
RMTPayload_FieldNumber_Body = 2,
};
// A block of data, to simply increase gRPC message size.
@interface RMTPayload : GPBMessage
// The type of data in body.
@property(nonatomic, readwrite) RMTPayloadType type;
// Primary contents of payload.
@property(nonatomic, readwrite, copy) NSData *body;
@end
int32_t RMTPayload_Type_RawValue(RMTPayload *message);
void SetRMTPayload_Type_RawValue(RMTPayload *message, int32_t value);
#pragma mark - RMTSimpleRequest
typedef GPB_ENUM(RMTSimpleRequest_FieldNumber) {
RMTSimpleRequest_FieldNumber_ResponseType = 1,
RMTSimpleRequest_FieldNumber_ResponseSize = 2,
RMTSimpleRequest_FieldNumber_Payload = 3,
RMTSimpleRequest_FieldNumber_FillUsername = 4,
RMTSimpleRequest_FieldNumber_FillOauthScope = 5,
};
// Unary request.
@interface RMTSimpleRequest : GPBMessage
// Desired payload type in the response from the server.
// If response_type is RANDOM, server randomly chooses one from other formats.
@property(nonatomic, readwrite) RMTPayloadType responseType;
// Desired payload size in the response from the server.
// If response_type is COMPRESSABLE, this denotes the size before compression.
@property(nonatomic, readwrite) int32_t responseSize;
// Optional input payload sent along with the request.
@property(nonatomic, readwrite) BOOL hasPayload;
@property(nonatomic, readwrite, strong) RMTPayload *payload;
// Whether SimpleResponse should include username.
@property(nonatomic, readwrite) BOOL fillUsername;
// Whether SimpleResponse should include OAuth scope.
@property(nonatomic, readwrite) BOOL fillOauthScope;
@end
int32_t RMTSimpleRequest_ResponseType_RawValue(RMTSimpleRequest *message);
void SetRMTSimpleRequest_ResponseType_RawValue(RMTSimpleRequest *message, int32_t value);
#pragma mark - RMTSimpleResponse
typedef GPB_ENUM(RMTSimpleResponse_FieldNumber) {
RMTSimpleResponse_FieldNumber_Payload = 1,
RMTSimpleResponse_FieldNumber_Username = 2,
RMTSimpleResponse_FieldNumber_OauthScope = 3,
};
// Unary response, as configured by the request.
@interface RMTSimpleResponse : GPBMessage
// Payload to increase message size.
@property(nonatomic, readwrite) BOOL hasPayload;
@property(nonatomic, readwrite, strong) RMTPayload *payload;
// The user the request came from, for verifying authentication was
// successful when the client expected it.
@property(nonatomic, readwrite, copy) NSString *username;
// OAuth scope.
@property(nonatomic, readwrite, copy) NSString *oauthScope;
@end
#pragma mark - RMTStreamingInputCallRequest
typedef GPB_ENUM(RMTStreamingInputCallRequest_FieldNumber) {
RMTStreamingInputCallRequest_FieldNumber_Payload = 1,
};
// Client-streaming request.
@interface RMTStreamingInputCallRequest : GPBMessage
// Optional input payload sent along with the request.
@property(nonatomic, readwrite) BOOL hasPayload;
@property(nonatomic, readwrite, strong) RMTPayload *payload;
@end
#pragma mark - RMTStreamingInputCallResponse
typedef GPB_ENUM(RMTStreamingInputCallResponse_FieldNumber) {
RMTStreamingInputCallResponse_FieldNumber_AggregatedPayloadSize = 1,
};
// Client-streaming response.
@interface RMTStreamingInputCallResponse : GPBMessage
// Aggregated size of payloads received from the client.
@property(nonatomic, readwrite) int32_t aggregatedPayloadSize;
@end
#pragma mark - RMTResponseParameters
typedef GPB_ENUM(RMTResponseParameters_FieldNumber) {
RMTResponseParameters_FieldNumber_Size = 1,
RMTResponseParameters_FieldNumber_IntervalUs = 2,
};
// Configuration for a particular response.
@interface RMTResponseParameters : GPBMessage
// Desired payload sizes in responses from the server.
// If response_type is COMPRESSABLE, this denotes the size before compression.
@property(nonatomic, readwrite) int32_t size;
// Desired interval between consecutive responses in the response stream in
// microseconds.
@property(nonatomic, readwrite) int32_t intervalUs;
@end
#pragma mark - RMTStreamingOutputCallRequest
typedef GPB_ENUM(RMTStreamingOutputCallRequest_FieldNumber) {
RMTStreamingOutputCallRequest_FieldNumber_ResponseType = 1,
RMTStreamingOutputCallRequest_FieldNumber_ResponseParametersArray = 2,
RMTStreamingOutputCallRequest_FieldNumber_Payload = 3,
};
// Server-streaming request.
@interface RMTStreamingOutputCallRequest : GPBMessage
// Desired payload type in the response from the server.
// If response_type is RANDOM, the payload from each response in the stream
// might be of different types. This is to simulate a mixed type of payload
// stream.
@property(nonatomic, readwrite) RMTPayloadType responseType;
// Configuration for each expected response message.
// |responseParametersArray| contains |RMTResponseParameters|
@property(nonatomic, readwrite, strong) NSMutableArray *responseParametersArray;
// Optional input payload sent along with the request.
@property(nonatomic, readwrite) BOOL hasPayload;
@property(nonatomic, readwrite, strong) RMTPayload *payload;
@end
int32_t RMTStreamingOutputCallRequest_ResponseType_RawValue(RMTStreamingOutputCallRequest *message);
void SetRMTStreamingOutputCallRequest_ResponseType_RawValue(RMTStreamingOutputCallRequest *message, int32_t value);
#pragma mark - RMTStreamingOutputCallResponse
typedef GPB_ENUM(RMTStreamingOutputCallResponse_FieldNumber) {
RMTStreamingOutputCallResponse_FieldNumber_Payload = 1,
};
// Server-streaming response, as configured by the request and parameters.
@interface RMTStreamingOutputCallResponse : GPBMessage
// Payload to increase response size.
@property(nonatomic, readwrite) BOOL hasPayload;
@property(nonatomic, readwrite, strong) RMTPayload *payload;
@end
CF_EXTERN_C_END

@ -1,603 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: messages.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
#import "Messages.pbobjc.h"
#pragma mark - RMTMessagesRoot
@implementation RMTMessagesRoot
@end
static GPBFileDescriptor *RMTMessagesRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"grpc.testing"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - Enum RMTPayloadType
GPBEnumDescriptor *RMTPayloadType_EnumDescriptor(void) {
static GPBEnumDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageEnumValueDescription values[] = {
{ .name = "Compressable", .number = RMTPayloadType_Compressable },
{ .name = "Uncompressable", .number = RMTPayloadType_Uncompressable },
{ .name = "Random", .number = RMTPayloadType_Random },
};
descriptor = [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(RMTPayloadType)
values:values
valueCount:sizeof(values) / sizeof(GPBMessageEnumValueDescription)
enumVerifier:RMTPayloadType_IsValidValue];
}
return descriptor;
}
BOOL RMTPayloadType_IsValidValue(int32_t value__) {
switch (value__) {
case RMTPayloadType_Compressable:
case RMTPayloadType_Uncompressable:
case RMTPayloadType_Random:
return YES;
default:
return NO;
}
}
#pragma mark - RMTPayload
@implementation RMTPayload
@dynamic type;
@dynamic body;
typedef struct RMTPayload_Storage {
uint32_t _has_storage_[1];
RMTPayloadType type;
NSData *body;
} RMTPayload_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "type",
.number = RMTPayload_FieldNumber_Type,
.hasIndex = 0,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.type = GPBTypeEnum,
.offset = offsetof(RMTPayload_Storage, type),
.defaultValue.valueEnum = RMTPayloadType_Compressable,
.typeSpecific.enumDescFunc = RMTPayloadType_EnumDescriptor,
.fieldOptions = NULL,
},
{
.name = "body",
.number = RMTPayload_FieldNumber_Body,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeData,
.offset = offsetof(RMTPayload_Storage, body),
.defaultValue.valueData = nil,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTPayload class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTPayload_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
int32_t RMTPayload_Type_RawValue(RMTPayload *message) {
GPBDescriptor *descriptor = [RMTPayload descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTPayload_FieldNumber_Type];
return GPBGetInt32IvarWithField(message, field);
}
void SetRMTPayload_Type_RawValue(RMTPayload *message, int32_t value) {
GPBDescriptor *descriptor = [RMTPayload descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTPayload_FieldNumber_Type];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - RMTSimpleRequest
@implementation RMTSimpleRequest
@dynamic responseType;
@dynamic responseSize;
@dynamic hasPayload, payload;
@dynamic fillUsername;
@dynamic fillOauthScope;
typedef struct RMTSimpleRequest_Storage {
uint32_t _has_storage_[1];
BOOL fillUsername;
BOOL fillOauthScope;
RMTPayloadType responseType;
int32_t responseSize;
RMTPayload *payload;
} RMTSimpleRequest_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "responseType",
.number = RMTSimpleRequest_FieldNumber_ResponseType,
.hasIndex = 0,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.type = GPBTypeEnum,
.offset = offsetof(RMTSimpleRequest_Storage, responseType),
.defaultValue.valueEnum = RMTPayloadType_Compressable,
.typeSpecific.enumDescFunc = RMTPayloadType_EnumDescriptor,
.fieldOptions = NULL,
},
{
.name = "responseSize",
.number = RMTSimpleRequest_FieldNumber_ResponseSize,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RMTSimpleRequest_Storage, responseSize),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "payload",
.number = RMTSimpleRequest_FieldNumber_Payload,
.hasIndex = 2,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RMTSimpleRequest_Storage, payload),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTPayload),
.fieldOptions = NULL,
},
{
.name = "fillUsername",
.number = RMTSimpleRequest_FieldNumber_FillUsername,
.hasIndex = 3,
.flags = GPBFieldOptional,
.type = GPBTypeBool,
.offset = offsetof(RMTSimpleRequest_Storage, fillUsername),
.defaultValue.valueBool = NO,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "fillOauthScope",
.number = RMTSimpleRequest_FieldNumber_FillOauthScope,
.hasIndex = 4,
.flags = GPBFieldOptional,
.type = GPBTypeBool,
.offset = offsetof(RMTSimpleRequest_Storage, fillOauthScope),
.defaultValue.valueBool = NO,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTSimpleRequest class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTSimpleRequest_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
int32_t RMTSimpleRequest_ResponseType_RawValue(RMTSimpleRequest *message) {
GPBDescriptor *descriptor = [RMTSimpleRequest descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTSimpleRequest_FieldNumber_ResponseType];
return GPBGetInt32IvarWithField(message, field);
}
void SetRMTSimpleRequest_ResponseType_RawValue(RMTSimpleRequest *message, int32_t value) {
GPBDescriptor *descriptor = [RMTSimpleRequest descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTSimpleRequest_FieldNumber_ResponseType];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - RMTSimpleResponse
@implementation RMTSimpleResponse
@dynamic hasPayload, payload;
@dynamic username;
@dynamic oauthScope;
typedef struct RMTSimpleResponse_Storage {
uint32_t _has_storage_[1];
RMTPayload *payload;
NSString *username;
NSString *oauthScope;
} RMTSimpleResponse_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "payload",
.number = RMTSimpleResponse_FieldNumber_Payload,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RMTSimpleResponse_Storage, payload),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTPayload),
.fieldOptions = NULL,
},
{
.name = "username",
.number = RMTSimpleResponse_FieldNumber_Username,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeString,
.offset = offsetof(RMTSimpleResponse_Storage, username),
.defaultValue.valueString = nil,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "oauthScope",
.number = RMTSimpleResponse_FieldNumber_OauthScope,
.hasIndex = 2,
.flags = GPBFieldOptional,
.type = GPBTypeString,
.offset = offsetof(RMTSimpleResponse_Storage, oauthScope),
.defaultValue.valueString = nil,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTSimpleResponse class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTSimpleResponse_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RMTStreamingInputCallRequest
@implementation RMTStreamingInputCallRequest
@dynamic hasPayload, payload;
typedef struct RMTStreamingInputCallRequest_Storage {
uint32_t _has_storage_[1];
RMTPayload *payload;
} RMTStreamingInputCallRequest_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "payload",
.number = RMTStreamingInputCallRequest_FieldNumber_Payload,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RMTStreamingInputCallRequest_Storage, payload),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTPayload),
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTStreamingInputCallRequest class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTStreamingInputCallRequest_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RMTStreamingInputCallResponse
@implementation RMTStreamingInputCallResponse
@dynamic aggregatedPayloadSize;
typedef struct RMTStreamingInputCallResponse_Storage {
uint32_t _has_storage_[1];
int32_t aggregatedPayloadSize;
} RMTStreamingInputCallResponse_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "aggregatedPayloadSize",
.number = RMTStreamingInputCallResponse_FieldNumber_AggregatedPayloadSize,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RMTStreamingInputCallResponse_Storage, aggregatedPayloadSize),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTStreamingInputCallResponse class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTStreamingInputCallResponse_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RMTResponseParameters
@implementation RMTResponseParameters
@dynamic size;
@dynamic intervalUs;
typedef struct RMTResponseParameters_Storage {
uint32_t _has_storage_[1];
int32_t size;
int32_t intervalUs;
} RMTResponseParameters_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "size",
.number = RMTResponseParameters_FieldNumber_Size,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RMTResponseParameters_Storage, size),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "intervalUs",
.number = RMTResponseParameters_FieldNumber_IntervalUs,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RMTResponseParameters_Storage, intervalUs),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTResponseParameters class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTResponseParameters_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RMTStreamingOutputCallRequest
@implementation RMTStreamingOutputCallRequest
@dynamic responseType;
@dynamic responseParametersArray;
@dynamic hasPayload, payload;
typedef struct RMTStreamingOutputCallRequest_Storage {
uint32_t _has_storage_[1];
RMTPayloadType responseType;
NSMutableArray *responseParametersArray;
RMTPayload *payload;
} RMTStreamingOutputCallRequest_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "responseType",
.number = RMTStreamingOutputCallRequest_FieldNumber_ResponseType,
.hasIndex = 0,
.flags = GPBFieldOptional | GPBFieldHasEnumDescriptor,
.type = GPBTypeEnum,
.offset = offsetof(RMTStreamingOutputCallRequest_Storage, responseType),
.defaultValue.valueEnum = RMTPayloadType_Compressable,
.typeSpecific.enumDescFunc = RMTPayloadType_EnumDescriptor,
.fieldOptions = NULL,
},
{
.name = "responseParametersArray",
.number = RMTStreamingOutputCallRequest_FieldNumber_ResponseParametersArray,
.hasIndex = GPBNoHasBit,
.flags = GPBFieldRepeated,
.type = GPBTypeMessage,
.offset = offsetof(RMTStreamingOutputCallRequest_Storage, responseParametersArray),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTResponseParameters),
.fieldOptions = NULL,
},
{
.name = "payload",
.number = RMTStreamingOutputCallRequest_FieldNumber_Payload,
.hasIndex = 2,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RMTStreamingOutputCallRequest_Storage, payload),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTPayload),
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTStreamingOutputCallRequest class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTStreamingOutputCallRequest_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
int32_t RMTStreamingOutputCallRequest_ResponseType_RawValue(RMTStreamingOutputCallRequest *message) {
GPBDescriptor *descriptor = [RMTStreamingOutputCallRequest descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTStreamingOutputCallRequest_FieldNumber_ResponseType];
return GPBGetInt32IvarWithField(message, field);
}
void SetRMTStreamingOutputCallRequest_ResponseType_RawValue(RMTStreamingOutputCallRequest *message, int32_t value) {
GPBDescriptor *descriptor = [RMTStreamingOutputCallRequest descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:RMTStreamingOutputCallRequest_FieldNumber_ResponseType];
GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);
}
#pragma mark - RMTStreamingOutputCallResponse
@implementation RMTStreamingOutputCallResponse
@dynamic hasPayload, payload;
typedef struct RMTStreamingOutputCallResponse_Storage {
uint32_t _has_storage_[1];
RMTPayload *payload;
} RMTStreamingOutputCallResponse_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "payload",
.number = RMTStreamingOutputCallResponse_FieldNumber_Payload,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RMTStreamingOutputCallResponse_Storage, payload),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RMTPayload),
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTStreamingOutputCallResponse class]
rootClass:[RMTMessagesRoot class]
file:RMTMessagesRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RMTStreamingOutputCallResponse_Storage)
wireFormat:NO];
}
return descriptor;
}
@end

@ -1,24 +1,26 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'RemoteTest' s.name = "RemoteTest"
s.version = '0.0.1' s.version = "0.0.1"
s.summary = 'Protobuf library generated from test.proto, messages.proto, and empty.proto' s.license = "New BSD"
s.homepage = 'https://github.com/grpc/grpc/tree/master/src/objective-c/examples/Sample/RemoteTestClient'
s.license = 'New BSD'
s.authors = { 'Jorge Canizales' => 'jcanizales@google.com' }
s.ios.deployment_target = '6.0' s.ios.deployment_target = "6.0"
s.osx.deployment_target = '10.8' s.osx.deployment_target = "10.8"
s.subspec 'Messages' do |ms| # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
ms.source_files = '*.pbobjc.{h,m}' s.prepare_command = "protoc --objc_out=. --objcgrpc_out=. *.proto **/*.proto"
s.subspec "Messages" do |ms|
ms.source_files = "*.pbobjc.{h,m}", "**/*.pbobjc.{h,m}"
ms.header_mappings_dir = "."
ms.requires_arc = false ms.requires_arc = false
ms.dependency 'Protobuf', '~> 3.0' ms.dependency "Protobuf", "~> 3.0.0-alpha-3"
end end
s.subspec 'Services' do |ss| s.subspec "Services" do |ss|
ss.source_files = '*.pbrpc.{h,m}' ss.source_files = "*.pbrpc.{h,m}", "**/*.pbrpc.{h,m}"
ss.header_mappings_dir = "."
ss.requires_arc = true ss.requires_arc = true
ss.dependency 'gRPC', '~> 0.0' ss.dependency "gRPC", "~> 0.5"
ss.dependency 'RemoteTest/Messages' ss.dependency "#{s.name}/Messages"
end end
end end

@ -1,12 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: test.proto
#import "GPBProtocolBuffers.h"
#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
#error This file was generated by a different version of protoc-gen-objc which is incompatible with your Protocol Buffer sources.
#endif
CF_EXTERN_C_BEGIN
CF_EXTERN_C_END

@ -1,9 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: test.proto
// File empty because all messages, extensions and enum have been filtered.
// Dummy symbol that will be stripped but will avoid linker warnings about
// no symbols in the .o form compiling this file.
static int RMTTestRoot_dummy __attribute__((unused,used)) = 0;

@ -1,59 +0,0 @@
#import "Test.pbobjc.h"
#import <gRPC/ProtoService.h>
#import "Empty.pbobjc.h"
#import "Messages.pbobjc.h"
@protocol GRXWriteable;
@protocol GRXWriter;
@protocol RMTTestService <NSObject>
#pragma mark EmptyCall(Empty) returns (Empty)
- (void)emptyCallWithRequest:(RMTEmpty *)request handler:(void(^)(RMTEmpty *response, NSError *error))handler;
- (ProtoRPC *)RPCToEmptyCallWithRequest:(RMTEmpty *)request handler:(void(^)(RMTEmpty *response, NSError *error))handler;
#pragma mark UnaryCall(SimpleRequest) returns (SimpleResponse)
- (void)unaryCallWithRequest:(RMTSimpleRequest *)request handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler;
- (ProtoRPC *)RPCToUnaryCallWithRequest:(RMTSimpleRequest *)request handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler;
#pragma mark StreamingOutputCall(StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)streamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
- (ProtoRPC *)RPCToStreamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
#pragma mark StreamingInputCall(stream StreamingInputCallRequest) returns (StreamingInputCallResponse)
- (void)streamingInputCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler;
- (ProtoRPC *)RPCToStreamingInputCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler;
#pragma mark FullDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)fullDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
- (ProtoRPC *)RPCToFullDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
#pragma mark HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)halfDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
- (ProtoRPC *)RPCToHalfDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler;
@end
// Basic service implementation, over gRPC, that only does marshalling and parsing.
@interface RMTTestService : ProtoService<RMTTestService>
- (instancetype)initWithHost:(NSString *)host NS_DESIGNATED_INITIALIZER;
@end

@ -1,96 +0,0 @@
#import "Test.pbrpc.h"
#import <gRPC/GRXWriteable.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/ProtoRPC.h>
static NSString *const kPackageName = @"grpc.testing";
static NSString *const kServiceName = @"TestService";
@implementation RMTTestService
// Designated initializer
- (instancetype)initWithHost:(NSString *)host {
return (self = [super initWithHost:host packageName:kPackageName serviceName:kServiceName]);
}
// Override superclass initializer to disallow different package and service names.
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName {
return [self initWithHost:host];
}
#pragma mark EmptyCall(Empty) returns (Empty)
- (void)emptyCallWithRequest:(RMTEmpty *)request handler:(void(^)(RMTEmpty *response, NSError *error))handler{
[[self RPCToEmptyCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToEmptyCallWithRequest:(RMTEmpty *)request handler:(void(^)(RMTEmpty *response, NSError *error))handler{
return [self RPCToMethod:@"EmptyCall"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[RMTEmpty class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark UnaryCall(SimpleRequest) returns (SimpleResponse)
- (void)unaryCallWithRequest:(RMTSimpleRequest *)request handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler{
[[self RPCToUnaryCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToUnaryCallWithRequest:(RMTSimpleRequest *)request handler:(void(^)(RMTSimpleResponse *response, NSError *error))handler{
return [self RPCToMethod:@"UnaryCall"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[RMTSimpleResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark StreamingOutputCall(StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)streamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
[[self RPCToStreamingOutputCallWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingOutputCallWithRequest:(RMTStreamingOutputCallRequest *)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
return [self RPCToMethod:@"StreamingOutputCall"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark StreamingInputCall(stream StreamingInputCallRequest) returns (StreamingInputCallResponse)
- (void)streamingInputCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler{
[[self RPCToStreamingInputCallWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToStreamingInputCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RMTStreamingInputCallResponse *response, NSError *error))handler{
return [self RPCToMethod:@"StreamingInputCall"
requestsWriter:request
responseClass:[RMTStreamingInputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark FullDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)fullDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
[[self RPCToFullDuplexCallWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToFullDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
return [self RPCToMethod:@"FullDuplexCall"
requestsWriter:request
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse)
- (void)halfDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
[[self RPCToHalfDuplexCallWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToHalfDuplexCallWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error))handler{
return [self RPCToMethod:@"HalfDuplexCall"
requestsWriter:request
responseClass:[RMTStreamingOutputCallResponse class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
@end

@ -1,134 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: route_guide.proto
#import "GPBProtocolBuffers.h"
#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000
#error This file was generated by a different version of protoc-gen-objc which is incompatible with your Protocol Buffer sources.
#endif
CF_EXTERN_C_BEGIN
@class RGDFeature;
@class RGDPoint;
@class RGDRectangle;
@class RGDRouteNote;
@class RGDRouteSummary;
#pragma mark - RGDRouteGuideRoot
@interface RGDRouteGuideRoot : GPBRootObject
@end
#pragma mark - RGDPoint
typedef GPB_ENUM(RGDPoint_FieldNumber) {
RGDPoint_FieldNumber_Latitude = 1,
RGDPoint_FieldNumber_Longitude = 2,
};
// Points are represented as latitude-longitude pairs in the E7 representation
// (degrees multiplied by 10**7 and rounded to the nearest integer).
// Latitudes should be in the range +/- 90 degrees and longitude should be in
// the range +/- 180 degrees (inclusive).
@interface RGDPoint : GPBMessage
@property(nonatomic, readwrite) int32_t latitude;
@property(nonatomic, readwrite) int32_t longitude;
@end
#pragma mark - RGDRectangle
typedef GPB_ENUM(RGDRectangle_FieldNumber) {
RGDRectangle_FieldNumber_Lo = 1,
RGDRectangle_FieldNumber_Hi = 2,
};
// A latitude-longitude rectangle, represented as two diagonally opposite
// points "lo" and "hi".
@interface RGDRectangle : GPBMessage
// One corner of the rectangle.
@property(nonatomic, readwrite) BOOL hasLo;
@property(nonatomic, readwrite, strong) RGDPoint *lo;
// The other corner of the rectangle.
@property(nonatomic, readwrite) BOOL hasHi;
@property(nonatomic, readwrite, strong) RGDPoint *hi;
@end
#pragma mark - RGDFeature
typedef GPB_ENUM(RGDFeature_FieldNumber) {
RGDFeature_FieldNumber_Name = 1,
RGDFeature_FieldNumber_Location = 2,
};
// A feature names something at a given point.
//
// If a feature could not be named, the name is empty.
@interface RGDFeature : GPBMessage
// The name of the feature.
@property(nonatomic, readwrite, copy) NSString *name;
// The point where the feature is detected.
@property(nonatomic, readwrite) BOOL hasLocation;
@property(nonatomic, readwrite, strong) RGDPoint *location;
@end
#pragma mark - RGDRouteNote
typedef GPB_ENUM(RGDRouteNote_FieldNumber) {
RGDRouteNote_FieldNumber_Location = 1,
RGDRouteNote_FieldNumber_Message = 2,
};
// A RouteNote is a message sent while at a given point.
@interface RGDRouteNote : GPBMessage
// The location from which the message is sent.
@property(nonatomic, readwrite) BOOL hasLocation;
@property(nonatomic, readwrite, strong) RGDPoint *location;
// The message to be sent.
@property(nonatomic, readwrite, copy) NSString *message;
@end
#pragma mark - RGDRouteSummary
typedef GPB_ENUM(RGDRouteSummary_FieldNumber) {
RGDRouteSummary_FieldNumber_PointCount = 1,
RGDRouteSummary_FieldNumber_FeatureCount = 2,
RGDRouteSummary_FieldNumber_Distance = 3,
RGDRouteSummary_FieldNumber_ElapsedTime = 4,
};
// A RouteSummary is received in response to a RecordRoute rpc.
//
// It contains the number of individual points received, the number of
// detected features, and the total distance covered as the cumulative sum of
// the distance between each point.
@interface RGDRouteSummary : GPBMessage
// The number of points received.
@property(nonatomic, readwrite) int32_t pointCount;
// The number of known features passed while traversing the route.
@property(nonatomic, readwrite) int32_t featureCount;
// The distance covered in metres.
@property(nonatomic, readwrite) int32_t distance;
// The duration of the traversal in seconds.
@property(nonatomic, readwrite) int32_t elapsedTime;
@end
CF_EXTERN_C_END

@ -1,355 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: route_guide.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
#import "RouteGuide.pbobjc.h"
#pragma mark - RGDRouteGuideRoot
@implementation RGDRouteGuideRoot
@end
static GPBFileDescriptor *RGDRouteGuideRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"grpc.example.routeguide"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - RGDPoint
@implementation RGDPoint
@dynamic latitude;
@dynamic longitude;
typedef struct RGDPoint_Storage {
uint32_t _has_storage_[1];
int32_t latitude;
int32_t longitude;
} RGDPoint_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "latitude",
.number = RGDPoint_FieldNumber_Latitude,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDPoint_Storage, latitude),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "longitude",
.number = RGDPoint_FieldNumber_Longitude,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDPoint_Storage, longitude),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RGDPoint class]
rootClass:[RGDRouteGuideRoot class]
file:RGDRouteGuideRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RGDPoint_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RGDRectangle
@implementation RGDRectangle
@dynamic hasLo, lo;
@dynamic hasHi, hi;
typedef struct RGDRectangle_Storage {
uint32_t _has_storage_[1];
RGDPoint *lo;
RGDPoint *hi;
} RGDRectangle_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "lo",
.number = RGDRectangle_FieldNumber_Lo,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RGDRectangle_Storage, lo),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RGDPoint),
.fieldOptions = NULL,
},
{
.name = "hi",
.number = RGDRectangle_FieldNumber_Hi,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RGDRectangle_Storage, hi),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RGDPoint),
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RGDRectangle class]
rootClass:[RGDRouteGuideRoot class]
file:RGDRouteGuideRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RGDRectangle_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RGDFeature
@implementation RGDFeature
@dynamic name;
@dynamic hasLocation, location;
typedef struct RGDFeature_Storage {
uint32_t _has_storage_[1];
NSString *name;
RGDPoint *location;
} RGDFeature_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "name",
.number = RGDFeature_FieldNumber_Name,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeString,
.offset = offsetof(RGDFeature_Storage, name),
.defaultValue.valueString = nil,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "location",
.number = RGDFeature_FieldNumber_Location,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RGDFeature_Storage, location),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RGDPoint),
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RGDFeature class]
rootClass:[RGDRouteGuideRoot class]
file:RGDRouteGuideRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RGDFeature_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RGDRouteNote
@implementation RGDRouteNote
@dynamic hasLocation, location;
@dynamic message;
typedef struct RGDRouteNote_Storage {
uint32_t _has_storage_[1];
RGDPoint *location;
NSString *message;
} RGDRouteNote_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "location",
.number = RGDRouteNote_FieldNumber_Location,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeMessage,
.offset = offsetof(RGDRouteNote_Storage, location),
.defaultValue.valueMessage = nil,
.typeSpecific.className = GPBStringifySymbol(RGDPoint),
.fieldOptions = NULL,
},
{
.name = "message",
.number = RGDRouteNote_FieldNumber_Message,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeString,
.offset = offsetof(RGDRouteNote_Storage, message),
.defaultValue.valueString = nil,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RGDRouteNote class]
rootClass:[RGDRouteGuideRoot class]
file:RGDRouteGuideRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RGDRouteNote_Storage)
wireFormat:NO];
}
return descriptor;
}
@end
#pragma mark - RGDRouteSummary
@implementation RGDRouteSummary
@dynamic pointCount;
@dynamic featureCount;
@dynamic distance;
@dynamic elapsedTime;
typedef struct RGDRouteSummary_Storage {
uint32_t _has_storage_[1];
int32_t pointCount;
int32_t featureCount;
int32_t distance;
int32_t elapsedTime;
} RGDRouteSummary_Storage;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = NULL;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "pointCount",
.number = RGDRouteSummary_FieldNumber_PointCount,
.hasIndex = 0,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDRouteSummary_Storage, pointCount),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "featureCount",
.number = RGDRouteSummary_FieldNumber_FeatureCount,
.hasIndex = 1,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDRouteSummary_Storage, featureCount),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "distance",
.number = RGDRouteSummary_FieldNumber_Distance,
.hasIndex = 2,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDRouteSummary_Storage, distance),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
{
.name = "elapsedTime",
.number = RGDRouteSummary_FieldNumber_ElapsedTime,
.hasIndex = 3,
.flags = GPBFieldOptional,
.type = GPBTypeInt32,
.offset = offsetof(RGDRouteSummary_Storage, elapsedTime),
.defaultValue.valueInt32 = 0,
.typeSpecific.className = NULL,
.fieldOptions = NULL,
},
};
descriptor = [GPBDescriptor allocDescriptorForClass:[RGDRouteSummary class]
rootClass:[RGDRouteGuideRoot class]
file:RGDRouteGuideRoot_FileDescriptor()
fields:fields
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription)
oneofs:NULL
oneofCount:0
enums:NULL
enumCount:0
ranges:NULL
rangeCount:0
storageSize:sizeof(RGDRouteSummary_Storage)
wireFormat:NO];
}
return descriptor;
}
@end

@ -1,43 +0,0 @@
#import "RouteGuide.pbobjc.h"
#import <gRPC/ProtoService.h>
@protocol GRXWriteable;
@protocol GRXWriter;
@protocol RGDRouteGuide <NSObject>
#pragma mark GetFeature(Point) returns (Feature)
- (void)getFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler;
- (ProtoRPC *)RPCToGetFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler;
#pragma mark ListFeatures(Rectangle) returns (stream Feature)
- (void)listFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler;
- (ProtoRPC *)RPCToListFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler;
#pragma mark RecordRoute(stream Point) returns (RouteSummary)
- (void)recordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler;
- (ProtoRPC *)RPCToRecordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler;
#pragma mark RouteChat(stream RouteNote) returns (stream RouteNote)
- (void)routeChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler;
- (ProtoRPC *)RPCToRouteChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler;
@end
// Basic service implementation, over gRPC, that only does marshalling and parsing.
@interface RGDRouteGuide : ProtoService<RGDRouteGuide>
- (instancetype)initWithHost:(NSString *)host NS_DESIGNATED_INITIALIZER;
@end

@ -1,72 +0,0 @@
#import "RouteGuide.pbrpc.h"
#import <gRPC/GRXWriteable.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/ProtoRPC.h>
static NSString *const kPackageName = @"grpc.example.routeguide";
static NSString *const kServiceName = @"RouteGuide";
@implementation RGDRouteGuide
// Designated initializer
- (instancetype)initWithHost:(NSString *)host {
return (self = [super initWithHost:host packageName:kPackageName serviceName:kServiceName]);
}
// Override superclass initializer to disallow different package and service names.
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName {
return [self initWithHost:host];
}
#pragma mark GetFeature(Point) returns (Feature)
- (void)getFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler{
[[self RPCToGetFeatureWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToGetFeatureWithRequest:(RGDPoint *)request handler:(void(^)(RGDFeature *response, NSError *error))handler{
return [self RPCToMethod:@"GetFeature"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[RGDFeature class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark ListFeatures(Rectangle) returns (stream Feature)
- (void)listFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler{
[[self RPCToListFeaturesWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToListFeaturesWithRequest:(RGDRectangle *)request handler:(void(^)(BOOL done, RGDFeature *response, NSError *error))handler{
return [self RPCToMethod:@"ListFeatures"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[RGDFeature class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
#pragma mark RecordRoute(stream Point) returns (RouteSummary)
- (void)recordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler{
[[self RPCToRecordRouteWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToRecordRouteWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(RGDRouteSummary *response, NSError *error))handler{
return [self RPCToMethod:@"RecordRoute"
requestsWriter:request
responseClass:[RGDRouteSummary class]
responsesWriteable:[GRXWriteable writeableWithSingleValueHandler:handler]];
}
#pragma mark RouteChat(stream RouteNote) returns (stream RouteNote)
- (void)routeChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler{
[[self RPCToRouteChatWithRequestsWriter:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (ProtoRPC *)RPCToRouteChatWithRequestsWriter:(id<GRXWriter>)request handler:(void(^)(BOOL done, RGDRouteNote *response, NSError *error))handler{
return [self RPCToMethod:@"RouteChat"
requestsWriter:request
responseClass:[RGDRouteNote class]
responsesWriteable:[GRXWriteable writeableWithStreamHandler:handler]];
}
@end

@ -0,0 +1,26 @@
Pod::Spec.new do |s|
s.name = "RouteGuide"
s.version = "0.0.1"
s.license = "New BSD"
s.ios.deployment_target = "6.0"
s.osx.deployment_target = "10.8"
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
s.prepare_command = "protoc --objc_out=. --objcgrpc_out=. *.proto **/*.proto"
s.subspec "Messages" do |ms|
ms.source_files = "*.pbobjc.{h,m}", "**/*.pbobjc.{h,m}"
ms.header_mappings_dir = "."
ms.requires_arc = false
ms.dependency "Protobuf", "~> 3.0.0-alpha-3"
end
s.subspec "Services" do |ss|
ss.source_files = "*.pbrpc.{h,m}", "**/*.pbrpc.{h,m}"
ss.header_mappings_dir = "."
ss.requires_arc = true
ss.dependency "gRPC", "~> 0.5"
ss.dependency "#{s.name}/Messages"
end
end

@ -1,24 +0,0 @@
Pod::Spec.new do |s|
s.name = 'Route_guide'
s.version = '0.0.1'
s.summary = 'Protobuf library generated from route_guide.proto'
s.homepage = 'https://github.com/grpc/grpc/tree/master/src/objective-c/examples/Sample/RouteGuideClient'
s.license = 'New BSD'
s.authors = { 'Jorge Canizales' => 'jcanizales@google.com' }
s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8'
s.subspec 'Messages' do |ms|
ms.source_files = '*.pbobjc.{h,m}'
ms.requires_arc = false
ms.dependency 'Protobuf', '~> 3.0'
end
s.subspec 'Services' do |ss|
ss.source_files = '*.pbrpc.{h,m}'
ss.requires_arc = true
ss.dependency 'gRPC', '~> 0.0'
ss.dependency 'Route_guide/Messages'
end
end

@ -29,7 +29,7 @@
syntax = "proto3"; syntax = "proto3";
package grpc.example.routeguide; package examples;
option objc_class_prefix = "RGD"; option objc_class_prefix = "RGD";

@ -38,56 +38,62 @@
#import <gRPC/GRPCMethodName.h> #import <gRPC/GRPCMethodName.h>
#import <gRPC/GRXWriter+Immediate.h> #import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/GRXWriteable.h> #import <gRPC/GRXWriteable.h>
#import <Route_guide/RouteGuide.pbobjc.h> #import <RouteGuide/RouteGuide.pbobjc.h>
#import <Route_guide/RouteGuide.pbrpc.h> #import <RouteGuide/RouteGuide.pbrpc.h>
// These tests require the gRPC-Java "RouteGuide" sample server to be running locally. To do so, // These tests require a gRPC "RouteGuide" sample server to be running locally. You can compile and
// install Gradle by following the instructions here: https://docs.gradle.org/current/userguide/installation.html // run one by following the instructions here: https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md#try-it-out
// And use it to run the server by following the instructions here: https://github.com/grpc/grpc-java/tree/master/examples // Be sure to have the C gRPC library installed in your system (for example, by having followed the
// instructions at https://github.com/grpc/homebrew-grpc
static NSString * const kRouteGuideHost = @"http://localhost:50051";
static NSString * const kPackage = @"examples";
static NSString * const kService = @"RouteGuide";
@interface LocalClearTextTests : XCTestCase @interface LocalClearTextTests : XCTestCase
@end @end
@implementation LocalClearTextTests @implementation LocalClearTextTests
- (void)testConnectionToLocalServer { // This test currently fails: see Issue #1907.
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."]; //- (void)testConnectionToLocalServer {
// __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
// This method isn't implemented by the local server. //
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.testing" // // This method isn't implemented by the local server.
interface:@"TestService" // GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
method:@"EmptyCall"]; // interface:kService
// method:@"EmptyCall"];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]]; //
// id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" //
method:method // GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
requestsWriter:requestsWriter]; // method:method
// requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { //
XCTFail(@"Received unexpected response: %@", value); // id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
} completionHandler:^(NSError *errorOrNil) { // XCTFail(@"Received unexpected response: %@", value);
XCTAssertNotNil(errorOrNil, @"Finished without error!"); // } completionHandler:^(NSError *errorOrNil) {
XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil); // XCTAssertNotNil(errorOrNil, @"Finished without error!");
[expectation fulfill]; // XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil);
}]; // [expectation fulfill];
// }];
[call startWithWriteable:responsesWriteable]; //
// [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2.0 handler:nil]; //
} // [self waitForExpectationsWithTimeout:8.0 handler:nil];
//}
- (void)testEmptyRPC { - (void)testEmptyRPC {
__weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."]; __weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide" GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
interface:@"RouteGuide" interface:kService
method:@"RecordRoute"]; method:@"RecordRoute"];
id<GRXWriter> requestsWriter = [GRXWriter emptyWriter]; id<GRXWriter> requestsWriter = [GRXWriter emptyWriter];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
method:method method:method
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
@ -109,8 +115,8 @@
__weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."]; __weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide" GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
interface:@"RouteGuide" interface:kService
method:@"GetFeature"]; method:@"GetFeature"];
RGDPoint *point = [RGDPoint message]; RGDPoint *point = [RGDPoint message];
@ -118,7 +124,7 @@
point.longitude = -15E7; point.longitude = -15E7;
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]]; id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
method:method method:method
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
@ -145,7 +151,7 @@
point.latitude = 28E7; point.latitude = 28E7;
point.longitude = -15E7; point.longitude = -15E7;
RGDRouteGuide *service = [[RGDRouteGuide alloc] initWithHost:@"http://127.0.0.1:8980"]; RGDRouteGuide *service = [[RGDRouteGuide alloc] initWithHost:kRouteGuideHost];
[service getFeatureWithRequest:point handler:^(RGDFeature *response, NSError *error) { [service getFeatureWithRequest:point handler:^(RGDFeature *response, NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error); XCTAssertNil(error, @"Finished with unexpected error: %@", error);
XCTAssertEqualObjects(point, response.location); XCTAssertEqualObjects(point, response.location);

@ -2,9 +2,8 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0' platform :ios, '8.0'
pod 'gRPC', :path => "../../.." pod 'gRPC', :path => "../../.."
pod 'Protobuf', :git => 'https://github.com/google/protobuf.git'
pod 'RemoteTest', :path => "../generated_libraries/RemoteTestClient" pod 'RemoteTest', :path => "../generated_libraries/RemoteTestClient"
pod 'Route_guide', :path => "../generated_libraries/RouteGuideClient" pod 'RouteGuide', :path => "../generated_libraries/RouteGuideClient"
link_with 'AllTests' link_with 'AllTests'

@ -32,29 +32,6 @@ require 'mkmf'
LIBDIR = RbConfig::CONFIG['libdir'] LIBDIR = RbConfig::CONFIG['libdir']
INCLUDEDIR = RbConfig::CONFIG['includedir'] INCLUDEDIR = RbConfig::CONFIG['includedir']
if ENV.key? 'GRPC_ROOT'
GRPC_ROOT = ENV['GRPC_ROOT']
else
grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
if File.exist?(File.join(grpc_root, 'include/grpc/grpc.h'))
GRPC_ROOT = grpc_root
else
GRPC_ROOT = nil
end
end
if ENV.key? 'CONFIG'
GRPC_CONFIG = ENV['CONFIG']
else
GRPC_CONFIG = 'opt'
end
if (ENV.key? 'GRPC_LIB_DIR') && (!GRPC_ROOT.nil?)
GRPC_LIB_DIR = File.join(GRPC_ROOT, ENV['GRPC_LIB_DIR'])
else
GRPC_LIB_DIR = File.join(File.join(GRPC_ROOT, 'libs'), GRPC_CONFIG)
end
HEADER_DIRS = [ HEADER_DIRS = [
# Search /opt/local (Mac source install) # Search /opt/local (Mac source install)
'/opt/local/include', '/opt/local/include',
@ -77,12 +54,26 @@ LIB_DIRS = [
LIBDIR LIBDIR
] ]
unless GRPC_ROOT.nil? # Check to see if GRPC_ROOT is defined or available
HEADER_DIRS.unshift File.join(GRPC_ROOT, 'include') grpc_root = ENV['GRPC_ROOT']
LIB_DIRS.unshift GRPC_LIB_DIR if grpc_root.nil?
unless File.exist?(File.join(GRPC_LIB_DIR, 'libgrpc.a')) r = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
system("make -C #{GRPC_ROOT} static_c CONFIG=#{GRPC_CONFIG}") grpc_root = r if File.exist?(File.join(r, 'include/grpc/grpc.h'))
end
# When grpc_root is available attempt to build the grpc core.
unless grpc_root.nil?
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
if ENV.key?('GRPC_LIB_DIR')
grpc_lib_dir = File.join(grpc_root, ENV['GRPC_LIB_DIR'])
else
grpc_lib_dir = File.join(File.join(grpc_root, 'libs'), grpc_config)
end
unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a'))
system("make -C #{grpc_root} static_c CONFIG=#{grpc_config}")
end end
HEADER_DIRS.unshift File.join(grpc_root, 'include')
LIB_DIRS.unshift grpc_lib_dir
end end
def crash(msg) def crash(msg)

@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'
s.required_ruby_version = '>= 2.0.0' s.required_ruby_version = '>= 2.0.0'
s.requirements << 'libgrpc ~> 0.6.0 needs to be installed' s.requirements << 'libgrpc ~> 0.9.1 needs to be installed'
s.files = `git ls-files`.split("\n") s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n")

@ -29,5 +29,5 @@
# GRPC contains the General RPC module. # GRPC contains the General RPC module.
module GRPC module GRPC
VERSION = '0.9.2' VERSION = '0.9.3'
end end

@ -146,6 +146,10 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0));
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1));
GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1));
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(configs[i]); grpc_end2end_tests(configs[i]);
} }

@ -79,5 +79,41 @@ ENV NUGET mono /var/local/NuGet.exe
# TODO(jtattermusch): add dependencies for other languages # TODO(jtattermusch): add dependencies for other languages
##################
# Node dependencies
# Install nvm
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
RUN /bin/bash -l -c "nvm install 0.12"
##################
# Ruby dependencies
# Install rvm
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RUN \curl -sSL https://get.rvm.io | bash -s stable
# Install Ruby 2.1
RUN /bin/bash -l -c "rvm install ruby-2.1"
RUN /bin/bash -l -c "rvm use --default ruby-2.1"
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
##################
# Python dependencies
# Install dependencies
RUN apt-get update && apt-get install -y \
python-all-dev \
python3-all-dev \
python-pip \
python-virtualenv
# Install Python packages from PyPI
RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.0.0a2
# Define the default command. # Define the default command.
CMD ["bash"] CMD ["bash"]

@ -42,9 +42,11 @@ then
echo "building $language on Linux" echo "building $language on Linux"
# Run tests inside docker # Run tests inside docker
docker run grpc/grpc_jenkins_slave bash -c "git clone --recursive $GIT_URL /var/local/git/grpc \ docker run grpc/grpc_jenkins_slave bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \
&& cd /var/local/git/grpc && git checkout -f $GIT_COMMIT \ && cd /var/local/git/grpc && git checkout -f $GIT_COMMIT \
&& git submodule update \ && git submodule update \
&& nvm use 0.12 \
&& rvm use ruby-2.1 \
&& tools/run_tests/run_tests.py -t -l $language" && tools/run_tests/run_tests.py -t -l $language"
elif [ "$platform" == "windows" ] elif [ "$platform" == "windows" ]
then then

@ -41,4 +41,4 @@ export LDFLAGS=-L`pwd`/libs/$CONFIG
cd src/node cd src/node
npm install npm install --unsafe-perm

Loading…
Cancel
Save