Merge remote-tracking branch 'upstream/master' into sync_async_mix

pull/4714/head
yang-g 9 years ago
commit 8053d2feb6
  1. 6
      .rspec
  2. 3
      BUILD
  3. 0
      Gemfile
  4. 2
      Makefile
  5. 21
      Rakefile
  6. 1
      binding.gyp
  7. 1
      build.yaml
  8. 1
      gRPC.podspec
  9. 416
      grpc.gemspec
  10. 2
      include/grpc++/client_context.h
  11. 2
      include/grpc++/security/credentials.h
  12. 12
      include/grpc/grpc.h
  13. 403
      package.json
  14. 13
      src/core/surface/call.c
  15. 73
      src/core/surface/validate_metadata.c
  16. 7
      src/core/transport/chttp2/bin_encoder.c
  17. 4
      src/core/transport/chttp2/bin_encoder.h
  18. 7
      src/core/transport/chttp2/hpack_encoder.c
  19. 7
      src/core/transport/chttp2/hpack_parser.c
  20. 36
      src/core/transport/metadata.c
  21. 4
      src/core/transport/metadata.h
  22. 10
      src/node/ext/call.cc
  23. 2
      src/node/ext/call_credentials.cc
  24. 50
      src/node/ext/node_grpc.cc
  25. 2
      src/node/ext/timeval.cc
  26. 6
      src/node/interop/async_delay_queue.js
  27. 4
      src/node/src/common.js
  28. 20
      src/node/src/metadata.js
  29. 6
      src/objective-c/GRPCClient/GRPCCall.h
  30. 21
      src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
  31. 33
      src/proto/gen_build_yaml.py
  32. 2
      src/proto/grpc/testing/duplicate/echo_duplicate.proto
  33. 2
      src/proto/grpc/testing/echo.proto
  34. 1
      src/python/grpcio/grpc_core_dependencies.py
  35. 6
      src/ruby/.rspec
  36. 38
      src/ruby/ext/grpc/extconf.rb
  37. 58
      src/ruby/ext/grpc/rb_call.c
  38. 27
      src/ruby/ext/grpc/rb_call_credentials.c
  39. 18
      src/ruby/ext/grpc/rb_channel.c
  40. 153
      src/ruby/ext/grpc/rb_event_thread.c
  41. 37
      src/ruby/ext/grpc/rb_event_thread.h
  42. 45
      src/ruby/grpc.gemspec
  43. 7
      src/ruby/lib/grpc.rb
  44. 18
      src/ruby/lib/grpc/generic/client_stub.rb
  45. 6
      src/ruby/lib/grpc/generic/service.rb
  46. 4
      src/ruby/lib/grpc/version.rb
  47. 25
      src/ruby/pb/test/client.rb
  48. 2
      src/ruby/spec/call_spec.rb
  49. 21
      src/ruby/spec/channel_spec.rb
  50. 2
      src/ruby/spec/client_server_spec.rb
  51. 3
      src/ruby/spec/generic/active_call_spec.rb
  52. 51
      src/ruby/spec/generic/client_stub_spec.rb
  53. 23
      src/ruby/spec/generic/rpc_server_spec.rb
  54. 9
      src/ruby/spec/generic/service_spec.rb
  55. 17
      src/ruby/spec/pb/health/checker_spec.rb
  56. 58
      templates/grpc.gemspec.template
  57. 74
      templates/package.json.template
  58. 6
      test/core/transport/chttp2/bin_encoder_test.c
  59. 2
      test/cpp/end2end/client_crash_test.cc
  60. 2
      test/cpp/end2end/client_crash_test_server.cc
  61. 2
      test/cpp/end2end/end2end_test.cc
  62. 2
      test/cpp/end2end/mock_test.cc
  63. 2
      test/cpp/end2end/server_crash_test.cc
  64. 2
      test/cpp/end2end/server_crash_test_client.cc
  65. 2
      test/cpp/end2end/shutdown_test.cc
  66. 2
      test/cpp/end2end/streaming_throughput_test.cc
  67. 2
      test/cpp/end2end/thread_stress_test.cc
  68. 2
      test/cpp/end2end/zookeeper_test.cc
  69. 2
      test/cpp/util/cli_call.cc
  70. 2
      test/cpp/util/cli_call_test.cc
  71. 3
      tools/distrib/check_copyright.py
  72. 1
      tools/distrib/clang_format_code.sh
  73. 1
      tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
  74. 1
      tools/doxygen/Doxyfile.core.internal
  75. 2
      tools/run_tests/build_ruby.sh
  76. 2
      tools/run_tests/run_interop_tests.py
  77. 2
      tools/run_tests/run_ruby.sh
  78. 2
      tools/run_tests/sources_and_headers.json
  79. 2
      vsprojects/vcxproj/grpc/grpc.vcxproj
  80. 3
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  81. 2
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  82. 3
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -0,0 +1,6 @@
-Isrc/ruby
-Isrc/ruby/pb
--backtrace
--require spec/spec_helper
--format documentation
--color

@ -385,6 +385,7 @@ cc_library(
"src/core/surface/server.c", "src/core/surface/server.c",
"src/core/surface/server_chttp2.c", "src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c", "src/core/surface/server_create.c",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c", "src/core/surface/version.c",
"src/core/transport/byte_stream.c", "src/core/transport/byte_stream.c",
"src/core/transport/chttp2/alpn.c", "src/core/transport/chttp2/alpn.c",
@ -656,6 +657,7 @@ cc_library(
"src/core/surface/server.c", "src/core/surface/server.c",
"src/core/surface/server_chttp2.c", "src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c", "src/core/surface/server_create.c",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c", "src/core/surface/version.c",
"src/core/transport/byte_stream.c", "src/core/transport/byte_stream.c",
"src/core/transport/chttp2/alpn.c", "src/core/transport/chttp2/alpn.c",
@ -1192,6 +1194,7 @@ objc_library(
"src/core/surface/server.c", "src/core/surface/server.c",
"src/core/surface/server_chttp2.c", "src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c", "src/core/surface/server_create.c",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c", "src/core/surface/version.c",
"src/core/transport/byte_stream.c", "src/core/transport/byte_stream.c",
"src/core/transport/chttp2/alpn.c", "src/core/transport/chttp2/alpn.c",

@ -2426,6 +2426,7 @@ LIBGRPC_SRC = \
src/core/surface/server.c \ src/core/surface/server.c \
src/core/surface/server_chttp2.c \ src/core/surface/server_chttp2.c \
src/core/surface/server_create.c \ src/core/surface/server_create.c \
src/core/surface/validate_metadata.c \
src/core/surface/version.c \ src/core/surface/version.c \
src/core/transport/byte_stream.c \ src/core/transport/byte_stream.c \
src/core/transport/chttp2/alpn.c \ src/core/transport/chttp2/alpn.c \
@ -2728,6 +2729,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/surface/server.c \ src/core/surface/server.c \
src/core/surface/server_chttp2.c \ src/core/surface/server_chttp2.c \
src/core/surface/server_create.c \ src/core/surface/server_create.c \
src/core/surface/validate_metadata.c \
src/core/surface/version.c \ src/core/surface/version.c \
src/core/transport/byte_stream.c \ src/core/transport/byte_stream.c \
src/core/transport/chttp2/alpn.c \ src/core/transport/chttp2/alpn.c \

@ -5,23 +5,28 @@ require 'rubocop/rake_task'
require 'bundler/gem_tasks' require 'bundler/gem_tasks'
# Add rubocop style checking tasks # Add rubocop style checking tasks
RuboCop::RakeTask.new RuboCop::RakeTask.new(:rubocop) do |task|
task.options = ['-c', 'src/ruby/.rubocop.yml']
task.patterns = ['src/ruby/{lib,spec}/**/*.rb']
end
# Add the extension compiler task # Add the extension compiler task
Rake::ExtensionTask.new 'grpc' do |ext| Rake::ExtensionTask.new 'grpc' do |ext|
ext.lib_dir = File.join('lib', 'grpc') ext.source_pattern = '**/*.{c,h}'
ext.ext_dir = File.join('src', 'ruby', 'ext', 'grpc')
ext.lib_dir = File.join('src', 'ruby', 'lib', 'grpc')
end end
# Define the test suites # Define the test suites
SPEC_SUITES = [ SPEC_SUITES = [
{ id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) }, { id: :wrapper, title: 'wrapper layer', files: %w(src/ruby/spec/*.rb) },
{ id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic), { id: :idiomatic, title: 'idiomatic layer', dir: %w(src/ruby/spec/generic),
tags: ['~bidi', '~server'] }, tags: ['~bidi', '~server'] },
{ id: :bidi, title: 'bidi tests', dir: %w(spec/generic), { id: :bidi, title: 'bidi tests', dir: %w(src/ruby/spec/generic),
tag: 'bidi' }, tag: 'bidi' },
{ id: :server, title: 'rpc server thread tests', dir: %w(spec/generic), { id: :server, title: 'rpc server thread tests', dir: %w(src/ruby/spec/generic),
tag: 'server' }, tag: 'server' },
{ id: :pb, title: 'protobuf service tests', dir: %w(spec/pb) } { id: :pb, title: 'protobuf service tests', dir: %w(src/ruby/spec/pb) }
] ]
namespace :suite do namespace :suite do
SPEC_SUITES.each do |suite| SPEC_SUITES.each do |suite|
@ -34,7 +39,7 @@ namespace :suite do
if suite[:dir] if suite[:dir]
suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] } suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
end end
helper = 'spec/spec_helper.rb' helper = 'src/ruby/spec/spec_helper.rb'
spec_files << helper unless spec_files.include?(helper) spec_files << helper unless spec_files.include?(helper)
t.pattern = spec_files t.pattern = spec_files

@ -279,6 +279,7 @@
'src/core/surface/server.c', 'src/core/surface/server.c',
'src/core/surface/server_chttp2.c', 'src/core/surface/server_chttp2.c',
'src/core/surface/server_create.c', 'src/core/surface/server_create.c',
'src/core/surface/validate_metadata.c',
'src/core/surface/version.c', 'src/core/surface/version.c',
'src/core/transport/byte_stream.c', 'src/core/transport/byte_stream.c',
'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/alpn.c',

@ -317,6 +317,7 @@ filegroups:
- src/core/surface/server.c - src/core/surface/server.c
- src/core/surface/server_chttp2.c - src/core/surface/server_chttp2.c
- src/core/surface/server_create.c - src/core/surface/server_create.c
- src/core/surface/validate_metadata.c
- src/core/surface/version.c - src/core/surface/version.c
- src/core/transport/byte_stream.c - src/core/transport/byte_stream.c
- src/core/transport/chttp2/alpn.c - src/core/transport/chttp2/alpn.c

@ -396,6 +396,7 @@ Pod::Spec.new do |s|
'src/core/surface/server.c', 'src/core/surface/server.c',
'src/core/surface/server_chttp2.c', 'src/core/surface/server_chttp2.c',
'src/core/surface/server_create.c', 'src/core/surface/server_create.c',
'src/core/surface/validate_metadata.c',
'src/core/surface/version.c', 'src/core/surface/version.c',
'src/core/transport/byte_stream.c', 'src/core/transport/byte_stream.c',
'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/alpn.c',

@ -0,0 +1,416 @@
# -*- ruby -*-
# encoding: utf-8
$LOAD_PATH.push File.expand_path('../src/ruby/lib', __FILE__)
require 'grpc/version'
Gem::Specification.new do |s|
s.name = 'grpc'
s.version = GRPC::VERSION
s.authors = ['gRPC Authors']
s.email = 'temiola@google.com'
s.homepage = 'https://github.com/google/grpc/tree/master/src/ruby'
s.summary = 'GRPC system in Ruby'
s.description = 'Send RPCs from Ruby using GRPC'
s.license = 'BSD-3-Clause'
s.required_ruby_version = '>= 2.0.0'
s.requirements << 'libgrpc ~> 0.11.0 needs to be installed'
s.files = %w( Rakefile Makefile )
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
s.files += Dir.glob('src/ruby/lib/**/*')
s.files += Dir.glob('src/ruby/pb/**/*')
s.files += Dir.glob('include/grpc/**/*')
s.test_files = Dir.glob('src/ruby/spec/**/*')
s.bindir = 'src/ruby/bin'
%w(math noproto).each do |b|
s.executables += ["#{b}_client.rb", "#{b}_server.rb"]
end
s.executables += %w(grpc_ruby_interop_client grpc_ruby_interop_server)
s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1'
s.add_dependency 'googleauth', '~> 0.5.1'
s.add_development_dependency 'bundler', '~> 1.9'
s.add_development_dependency 'logging', '~> 2.0'
s.add_development_dependency 'simplecov', '~> 0.9'
s.add_development_dependency 'rake', '~> 10.4'
s.add_development_dependency 'rake-compiler', '~> 0.9'
s.add_development_dependency 'rspec', '~> 3.2'
s.add_development_dependency 'rubocop', '~> 0.30.0'
s.add_development_dependency 'signet', '~>0.7.0'
s.extensions = %w(src/ruby/ext/grpc/extconf.rb)
s.files += %w( include/grpc/support/alloc.h )
s.files += %w( include/grpc/support/atm.h )
s.files += %w( include/grpc/support/atm_gcc_atomic.h )
s.files += %w( include/grpc/support/atm_gcc_sync.h )
s.files += %w( include/grpc/support/atm_win32.h )
s.files += %w( include/grpc/support/avl.h )
s.files += %w( include/grpc/support/cmdline.h )
s.files += %w( include/grpc/support/cpu.h )
s.files += %w( include/grpc/support/histogram.h )
s.files += %w( include/grpc/support/host_port.h )
s.files += %w( include/grpc/support/log.h )
s.files += %w( include/grpc/support/log_win32.h )
s.files += %w( include/grpc/support/port_platform.h )
s.files += %w( include/grpc/support/slice.h )
s.files += %w( include/grpc/support/slice_buffer.h )
s.files += %w( include/grpc/support/string_util.h )
s.files += %w( include/grpc/support/subprocess.h )
s.files += %w( include/grpc/support/sync.h )
s.files += %w( include/grpc/support/sync_generic.h )
s.files += %w( include/grpc/support/sync_posix.h )
s.files += %w( include/grpc/support/sync_win32.h )
s.files += %w( include/grpc/support/thd.h )
s.files += %w( include/grpc/support/time.h )
s.files += %w( include/grpc/support/tls.h )
s.files += %w( include/grpc/support/tls_gcc.h )
s.files += %w( include/grpc/support/tls_msvc.h )
s.files += %w( include/grpc/support/tls_pthread.h )
s.files += %w( include/grpc/support/useful.h )
s.files += %w( src/core/profiling/timers.h )
s.files += %w( src/core/support/block_annotate.h )
s.files += %w( src/core/support/env.h )
s.files += %w( src/core/support/file.h )
s.files += %w( src/core/support/murmur_hash.h )
s.files += %w( src/core/support/stack_lockfree.h )
s.files += %w( src/core/support/string.h )
s.files += %w( src/core/support/string_win32.h )
s.files += %w( src/core/support/thd_internal.h )
s.files += %w( src/core/support/time_precise.h )
s.files += %w( src/core/profiling/basic_timers.c )
s.files += %w( src/core/profiling/stap_timers.c )
s.files += %w( src/core/support/alloc.c )
s.files += %w( src/core/support/avl.c )
s.files += %w( src/core/support/cmdline.c )
s.files += %w( src/core/support/cpu_iphone.c )
s.files += %w( src/core/support/cpu_linux.c )
s.files += %w( src/core/support/cpu_posix.c )
s.files += %w( src/core/support/cpu_windows.c )
s.files += %w( src/core/support/env_linux.c )
s.files += %w( src/core/support/env_posix.c )
s.files += %w( src/core/support/env_win32.c )
s.files += %w( src/core/support/file.c )
s.files += %w( src/core/support/file_posix.c )
s.files += %w( src/core/support/file_win32.c )
s.files += %w( src/core/support/histogram.c )
s.files += %w( src/core/support/host_port.c )
s.files += %w( src/core/support/log.c )
s.files += %w( src/core/support/log_android.c )
s.files += %w( src/core/support/log_linux.c )
s.files += %w( src/core/support/log_posix.c )
s.files += %w( src/core/support/log_win32.c )
s.files += %w( src/core/support/murmur_hash.c )
s.files += %w( src/core/support/slice.c )
s.files += %w( src/core/support/slice_buffer.c )
s.files += %w( src/core/support/stack_lockfree.c )
s.files += %w( src/core/support/string.c )
s.files += %w( src/core/support/string_posix.c )
s.files += %w( src/core/support/string_win32.c )
s.files += %w( src/core/support/subprocess_posix.c )
s.files += %w( src/core/support/sync.c )
s.files += %w( src/core/support/sync_posix.c )
s.files += %w( src/core/support/sync_win32.c )
s.files += %w( src/core/support/thd.c )
s.files += %w( src/core/support/thd_posix.c )
s.files += %w( src/core/support/thd_win32.c )
s.files += %w( src/core/support/time.c )
s.files += %w( src/core/support/time_posix.c )
s.files += %w( src/core/support/time_precise.c )
s.files += %w( src/core/support/time_win32.c )
s.files += %w( src/core/support/tls_pthread.c )
s.files += %w( include/grpc/grpc_security.h )
s.files += %w( include/grpc/byte_buffer.h )
s.files += %w( include/grpc/byte_buffer_reader.h )
s.files += %w( include/grpc/compression.h )
s.files += %w( include/grpc/grpc.h )
s.files += %w( include/grpc/status.h )
s.files += %w( include/grpc/census.h )
s.files += %w( src/core/security/auth_filters.h )
s.files += %w( src/core/security/base64.h )
s.files += %w( src/core/security/credentials.h )
s.files += %w( src/core/security/handshake.h )
s.files += %w( src/core/security/json_token.h )
s.files += %w( src/core/security/jwt_verifier.h )
s.files += %w( src/core/security/secure_endpoint.h )
s.files += %w( src/core/security/security_connector.h )
s.files += %w( src/core/security/security_context.h )
s.files += %w( src/core/tsi/fake_transport_security.h )
s.files += %w( src/core/tsi/ssl_transport_security.h )
s.files += %w( src/core/tsi/ssl_types.h )
s.files += %w( src/core/tsi/transport_security.h )
s.files += %w( src/core/tsi/transport_security_interface.h )
s.files += %w( src/core/census/grpc_filter.h )
s.files += %w( src/core/channel/channel_args.h )
s.files += %w( src/core/channel/channel_stack.h )
s.files += %w( src/core/channel/client_channel.h )
s.files += %w( src/core/channel/client_uchannel.h )
s.files += %w( src/core/channel/compress_filter.h )
s.files += %w( src/core/channel/connected_channel.h )
s.files += %w( src/core/channel/context.h )
s.files += %w( src/core/channel/http_client_filter.h )
s.files += %w( src/core/channel/http_server_filter.h )
s.files += %w( src/core/channel/subchannel_call_holder.h )
s.files += %w( src/core/client_config/client_config.h )
s.files += %w( src/core/client_config/connector.h )
s.files += %w( src/core/client_config/initial_connect_string.h )
s.files += %w( src/core/client_config/lb_policies/pick_first.h )
s.files += %w( src/core/client_config/lb_policies/round_robin.h )
s.files += %w( src/core/client_config/lb_policy.h )
s.files += %w( src/core/client_config/lb_policy_factory.h )
s.files += %w( src/core/client_config/lb_policy_registry.h )
s.files += %w( src/core/client_config/resolver.h )
s.files += %w( src/core/client_config/resolver_factory.h )
s.files += %w( src/core/client_config/resolver_registry.h )
s.files += %w( src/core/client_config/resolvers/dns_resolver.h )
s.files += %w( src/core/client_config/resolvers/sockaddr_resolver.h )
s.files += %w( src/core/client_config/subchannel.h )
s.files += %w( src/core/client_config/subchannel_factory.h )
s.files += %w( src/core/client_config/uri_parser.h )
s.files += %w( src/core/compression/algorithm_metadata.h )
s.files += %w( src/core/compression/message_compress.h )
s.files += %w( src/core/debug/trace.h )
s.files += %w( src/core/httpcli/format_request.h )
s.files += %w( src/core/httpcli/httpcli.h )
s.files += %w( src/core/httpcli/parser.h )
s.files += %w( src/core/iomgr/closure.h )
s.files += %w( src/core/iomgr/endpoint.h )
s.files += %w( src/core/iomgr/endpoint_pair.h )
s.files += %w( src/core/iomgr/exec_ctx.h )
s.files += %w( src/core/iomgr/executor.h )
s.files += %w( src/core/iomgr/fd_posix.h )
s.files += %w( src/core/iomgr/iocp_windows.h )
s.files += %w( src/core/iomgr/iomgr.h )
s.files += %w( src/core/iomgr/iomgr_internal.h )
s.files += %w( src/core/iomgr/iomgr_posix.h )
s.files += %w( src/core/iomgr/pollset.h )
s.files += %w( src/core/iomgr/pollset_posix.h )
s.files += %w( src/core/iomgr/pollset_set.h )
s.files += %w( src/core/iomgr/pollset_set_posix.h )
s.files += %w( src/core/iomgr/pollset_set_windows.h )
s.files += %w( src/core/iomgr/pollset_windows.h )
s.files += %w( src/core/iomgr/resolve_address.h )
s.files += %w( src/core/iomgr/sockaddr.h )
s.files += %w( src/core/iomgr/sockaddr_posix.h )
s.files += %w( src/core/iomgr/sockaddr_utils.h )
s.files += %w( src/core/iomgr/sockaddr_win32.h )
s.files += %w( src/core/iomgr/socket_utils_posix.h )
s.files += %w( src/core/iomgr/socket_windows.h )
s.files += %w( src/core/iomgr/tcp_client.h )
s.files += %w( src/core/iomgr/tcp_posix.h )
s.files += %w( src/core/iomgr/tcp_server.h )
s.files += %w( src/core/iomgr/tcp_windows.h )
s.files += %w( src/core/iomgr/time_averaged_stats.h )
s.files += %w( src/core/iomgr/timer.h )
s.files += %w( src/core/iomgr/timer_heap.h )
s.files += %w( src/core/iomgr/timer_internal.h )
s.files += %w( src/core/iomgr/udp_server.h )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.h )
s.files += %w( src/core/iomgr/wakeup_fd_posix.h )
s.files += %w( src/core/iomgr/workqueue.h )
s.files += %w( src/core/iomgr/workqueue_posix.h )
s.files += %w( src/core/iomgr/workqueue_windows.h )
s.files += %w( src/core/json/json.h )
s.files += %w( src/core/json/json_common.h )
s.files += %w( src/core/json/json_reader.h )
s.files += %w( src/core/json/json_writer.h )
s.files += %w( src/core/statistics/census_interface.h )
s.files += %w( src/core/statistics/census_rpc_stats.h )
s.files += %w( src/core/surface/api_trace.h )
s.files += %w( src/core/surface/call.h )
s.files += %w( src/core/surface/call_test_only.h )
s.files += %w( src/core/surface/channel.h )
s.files += %w( src/core/surface/completion_queue.h )
s.files += %w( src/core/surface/event_string.h )
s.files += %w( src/core/surface/init.h )
s.files += %w( src/core/surface/server.h )
s.files += %w( src/core/surface/surface_trace.h )
s.files += %w( src/core/transport/byte_stream.h )
s.files += %w( src/core/transport/chttp2/alpn.h )
s.files += %w( src/core/transport/chttp2/bin_encoder.h )
s.files += %w( src/core/transport/chttp2/frame.h )
s.files += %w( src/core/transport/chttp2/frame_data.h )
s.files += %w( src/core/transport/chttp2/frame_goaway.h )
s.files += %w( src/core/transport/chttp2/frame_ping.h )
s.files += %w( src/core/transport/chttp2/frame_rst_stream.h )
s.files += %w( src/core/transport/chttp2/frame_settings.h )
s.files += %w( src/core/transport/chttp2/frame_window_update.h )
s.files += %w( src/core/transport/chttp2/hpack_encoder.h )
s.files += %w( src/core/transport/chttp2/hpack_parser.h )
s.files += %w( src/core/transport/chttp2/hpack_table.h )
s.files += %w( src/core/transport/chttp2/http2_errors.h )
s.files += %w( src/core/transport/chttp2/huffsyms.h )
s.files += %w( src/core/transport/chttp2/incoming_metadata.h )
s.files += %w( src/core/transport/chttp2/internal.h )
s.files += %w( src/core/transport/chttp2/status_conversion.h )
s.files += %w( src/core/transport/chttp2/stream_map.h )
s.files += %w( src/core/transport/chttp2/timeout_encoding.h )
s.files += %w( src/core/transport/chttp2/varint.h )
s.files += %w( src/core/transport/chttp2_transport.h )
s.files += %w( src/core/transport/connectivity_state.h )
s.files += %w( src/core/transport/metadata.h )
s.files += %w( src/core/transport/metadata_batch.h )
s.files += %w( src/core/transport/static_metadata.h )
s.files += %w( src/core/transport/transport.h )
s.files += %w( src/core/transport/transport_impl.h )
s.files += %w( src/core/census/aggregation.h )
s.files += %w( src/core/census/context.h )
s.files += %w( src/core/census/rpc_metric_id.h )
s.files += %w( src/core/httpcli/httpcli_security_connector.c )
s.files += %w( src/core/security/base64.c )
s.files += %w( src/core/security/client_auth_filter.c )
s.files += %w( src/core/security/credentials.c )
s.files += %w( src/core/security/credentials_metadata.c )
s.files += %w( src/core/security/credentials_posix.c )
s.files += %w( src/core/security/credentials_win32.c )
s.files += %w( src/core/security/google_default_credentials.c )
s.files += %w( src/core/security/handshake.c )
s.files += %w( src/core/security/json_token.c )
s.files += %w( src/core/security/jwt_verifier.c )
s.files += %w( src/core/security/secure_endpoint.c )
s.files += %w( src/core/security/security_connector.c )
s.files += %w( src/core/security/security_context.c )
s.files += %w( src/core/security/server_auth_filter.c )
s.files += %w( src/core/security/server_secure_chttp2.c )
s.files += %w( src/core/surface/init_secure.c )
s.files += %w( src/core/surface/secure_channel_create.c )
s.files += %w( src/core/tsi/fake_transport_security.c )
s.files += %w( src/core/tsi/ssl_transport_security.c )
s.files += %w( src/core/tsi/transport_security.c )
s.files += %w( src/core/census/grpc_context.c )
s.files += %w( src/core/census/grpc_filter.c )
s.files += %w( src/core/channel/channel_args.c )
s.files += %w( src/core/channel/channel_stack.c )
s.files += %w( src/core/channel/client_channel.c )
s.files += %w( src/core/channel/client_uchannel.c )
s.files += %w( src/core/channel/compress_filter.c )
s.files += %w( src/core/channel/connected_channel.c )
s.files += %w( src/core/channel/http_client_filter.c )
s.files += %w( src/core/channel/http_server_filter.c )
s.files += %w( src/core/channel/subchannel_call_holder.c )
s.files += %w( src/core/client_config/client_config.c )
s.files += %w( src/core/client_config/connector.c )
s.files += %w( src/core/client_config/default_initial_connect_string.c )
s.files += %w( src/core/client_config/initial_connect_string.c )
s.files += %w( src/core/client_config/lb_policies/pick_first.c )
s.files += %w( src/core/client_config/lb_policies/round_robin.c )
s.files += %w( src/core/client_config/lb_policy.c )
s.files += %w( src/core/client_config/lb_policy_factory.c )
s.files += %w( src/core/client_config/lb_policy_registry.c )
s.files += %w( src/core/client_config/resolver.c )
s.files += %w( src/core/client_config/resolver_factory.c )
s.files += %w( src/core/client_config/resolver_registry.c )
s.files += %w( src/core/client_config/resolvers/dns_resolver.c )
s.files += %w( src/core/client_config/resolvers/sockaddr_resolver.c )
s.files += %w( src/core/client_config/subchannel.c )
s.files += %w( src/core/client_config/subchannel_factory.c )
s.files += %w( src/core/client_config/uri_parser.c )
s.files += %w( src/core/compression/algorithm.c )
s.files += %w( src/core/compression/message_compress.c )
s.files += %w( src/core/debug/trace.c )
s.files += %w( src/core/httpcli/format_request.c )
s.files += %w( src/core/httpcli/httpcli.c )
s.files += %w( src/core/httpcli/parser.c )
s.files += %w( src/core/iomgr/closure.c )
s.files += %w( src/core/iomgr/endpoint.c )
s.files += %w( src/core/iomgr/endpoint_pair_posix.c )
s.files += %w( src/core/iomgr/endpoint_pair_windows.c )
s.files += %w( src/core/iomgr/exec_ctx.c )
s.files += %w( src/core/iomgr/executor.c )
s.files += %w( src/core/iomgr/fd_posix.c )
s.files += %w( src/core/iomgr/iocp_windows.c )
s.files += %w( src/core/iomgr/iomgr.c )
s.files += %w( src/core/iomgr/iomgr_posix.c )
s.files += %w( src/core/iomgr/iomgr_windows.c )
s.files += %w( src/core/iomgr/pollset_multipoller_with_epoll.c )
s.files += %w( src/core/iomgr/pollset_multipoller_with_poll_posix.c )
s.files += %w( src/core/iomgr/pollset_posix.c )
s.files += %w( src/core/iomgr/pollset_set_posix.c )
s.files += %w( src/core/iomgr/pollset_set_windows.c )
s.files += %w( src/core/iomgr/pollset_windows.c )
s.files += %w( src/core/iomgr/resolve_address_posix.c )
s.files += %w( src/core/iomgr/resolve_address_windows.c )
s.files += %w( src/core/iomgr/sockaddr_utils.c )
s.files += %w( src/core/iomgr/socket_utils_common_posix.c )
s.files += %w( src/core/iomgr/socket_utils_linux.c )
s.files += %w( src/core/iomgr/socket_utils_posix.c )
s.files += %w( src/core/iomgr/socket_windows.c )
s.files += %w( src/core/iomgr/tcp_client_posix.c )
s.files += %w( src/core/iomgr/tcp_client_windows.c )
s.files += %w( src/core/iomgr/tcp_posix.c )
s.files += %w( src/core/iomgr/tcp_server_posix.c )
s.files += %w( src/core/iomgr/tcp_server_windows.c )
s.files += %w( src/core/iomgr/tcp_windows.c )
s.files += %w( src/core/iomgr/time_averaged_stats.c )
s.files += %w( src/core/iomgr/timer.c )
s.files += %w( src/core/iomgr/timer_heap.c )
s.files += %w( src/core/iomgr/udp_server.c )
s.files += %w( src/core/iomgr/wakeup_fd_eventfd.c )
s.files += %w( src/core/iomgr/wakeup_fd_nospecial.c )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.c )
s.files += %w( src/core/iomgr/wakeup_fd_posix.c )
s.files += %w( src/core/iomgr/workqueue_posix.c )
s.files += %w( src/core/iomgr/workqueue_windows.c )
s.files += %w( src/core/json/json.c )
s.files += %w( src/core/json/json_reader.c )
s.files += %w( src/core/json/json_string.c )
s.files += %w( src/core/json/json_writer.c )
s.files += %w( src/core/surface/api_trace.c )
s.files += %w( src/core/surface/byte_buffer.c )
s.files += %w( src/core/surface/byte_buffer_reader.c )
s.files += %w( src/core/surface/call.c )
s.files += %w( src/core/surface/call_details.c )
s.files += %w( src/core/surface/call_log_batch.c )
s.files += %w( src/core/surface/channel.c )
s.files += %w( src/core/surface/channel_connectivity.c )
s.files += %w( src/core/surface/channel_create.c )
s.files += %w( src/core/surface/channel_ping.c )
s.files += %w( src/core/surface/completion_queue.c )
s.files += %w( src/core/surface/event_string.c )
s.files += %w( src/core/surface/init.c )
s.files += %w( src/core/surface/lame_client.c )
s.files += %w( src/core/surface/metadata_array.c )
s.files += %w( src/core/surface/server.c )
s.files += %w( src/core/surface/server_chttp2.c )
s.files += %w( src/core/surface/server_create.c )
s.files += %w( src/core/surface/validate_metadata.c )
s.files += %w( src/core/surface/version.c )
s.files += %w( src/core/transport/byte_stream.c )
s.files += %w( src/core/transport/chttp2/alpn.c )
s.files += %w( src/core/transport/chttp2/bin_encoder.c )
s.files += %w( src/core/transport/chttp2/frame_data.c )
s.files += %w( src/core/transport/chttp2/frame_goaway.c )
s.files += %w( src/core/transport/chttp2/frame_ping.c )
s.files += %w( src/core/transport/chttp2/frame_rst_stream.c )
s.files += %w( src/core/transport/chttp2/frame_settings.c )
s.files += %w( src/core/transport/chttp2/frame_window_update.c )
s.files += %w( src/core/transport/chttp2/hpack_encoder.c )
s.files += %w( src/core/transport/chttp2/hpack_parser.c )
s.files += %w( src/core/transport/chttp2/hpack_table.c )
s.files += %w( src/core/transport/chttp2/huffsyms.c )
s.files += %w( src/core/transport/chttp2/incoming_metadata.c )
s.files += %w( src/core/transport/chttp2/parsing.c )
s.files += %w( src/core/transport/chttp2/status_conversion.c )
s.files += %w( src/core/transport/chttp2/stream_lists.c )
s.files += %w( src/core/transport/chttp2/stream_map.c )
s.files += %w( src/core/transport/chttp2/timeout_encoding.c )
s.files += %w( src/core/transport/chttp2/varint.c )
s.files += %w( src/core/transport/chttp2/writing.c )
s.files += %w( src/core/transport/chttp2_transport.c )
s.files += %w( src/core/transport/connectivity_state.c )
s.files += %w( src/core/transport/metadata.c )
s.files += %w( src/core/transport/metadata_batch.c )
s.files += %w( src/core/transport/static_metadata.c )
s.files += %w( src/core/transport/transport.c )
s.files += %w( src/core/transport/transport_op_string.c )
s.files += %w( src/core/census/context.c )
s.files += %w( src/core/census/initialize.c )
s.files += %w( src/core/census/operation.c )
s.files += %w( src/core/census/tracing.c )
end

@ -244,7 +244,7 @@ class ClientContext {
/// client’s identity, role, or whether it is authorized to make a particular /// client’s identity, role, or whether it is authorized to make a particular
/// call. /// call.
/// ///
/// \see https://github.com/grpc/grpc/blob/master/doc/grpc-auth-support.md /// \see http://www.grpc.io/docs/guides/auth.html
void set_credentials(const std::shared_ptr<CallCredentials>& creds) { void set_credentials(const std::shared_ptr<CallCredentials>& creds) {
creds_ = creds; creds_ = creds;
} }

@ -55,7 +55,7 @@ class SecureCallCredentials;
/// It can make various assertions, e.g., about the client’s identity, role /// It can make various assertions, e.g., about the client’s identity, role
/// for all the calls on that channel. /// for all the calls on that channel.
/// ///
/// \see https://github.com/grpc/grpc/blob/master/doc/grpc-auth-support.md /// \see http://www.grpc.io/docs/guides/auth.html
class ChannelCredentials : public GrpcLibrary { class ChannelCredentials : public GrpcLibrary {
public: public:
~ChannelCredentials() GRPC_OVERRIDE; ~ChannelCredentials() GRPC_OVERRIDE;

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -715,6 +715,16 @@ void grpc_server_destroy(grpc_server *server);
thread-safety issues raised by it should not be of concern. */ thread-safety issues raised by it should not be of concern. */
int grpc_tracer_set_enabled(const char *name, int enabled); int grpc_tracer_set_enabled(const char *name, int enabled);
/** Check whether a metadata key is legal (will be accepted by core) */
int grpc_header_key_is_legal(const char *key, size_t length);
/** Check whether a non-binary metadata value is legal (will be accepted by
core) */
int grpc_header_nonbin_value_is_legal(const char *value, size_t length);
/** Check whether a metadata key corresponds to a binary value */
int grpc_is_binary_header(const char *key, size_t length);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -31,13 +31,13 @@
"protobufjs": "^4.0.0" "protobufjs": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"async": "^0.9.0", "async": "^1.5.0",
"google-auth-library": "^0.9.2", "google-auth-library": "^0.9.2",
"istanbul": "^0.3.21", "istanbul": "^0.3.21",
"jsdoc": "^3.3.2", "jsdoc": "^3.3.2",
"jshint": "^2.5.0", "jshint": "^2.5.0",
"minimist": "^1.1.0", "minimist": "^1.1.0",
"mocha": "~1.21.0", "mocha": "^2.3.4",
"mocha-jenkins-reporter": "^0.1.9", "mocha-jenkins-reporter": "^0.1.9",
"mustache": "^2.0.0", "mustache": "^2.0.0",
"poisson-process": "^0.2.1" "poisson-process": "^0.2.1"
@ -48,14 +48,401 @@
"files": [ "files": [
"LICENSE", "LICENSE",
"src/node/README.md", "src/node/README.md",
"src/node/index.js",
"src/node/ext",
"src/node/health_check", "src/node/health_check",
"src/node/src", "src/proto",
"src/core",
"test/proto",
"include",
"etc", "etc",
"src/node/ext/byte_buffer.h",
"src/node/ext/call.h",
"src/node/ext/call_credentials.h",
"src/node/ext/channel.h",
"src/node/ext/channel_credentials.h",
"src/node/ext/completion_queue_async_worker.h",
"src/node/ext/server.h",
"src/node/ext/server_credentials.h",
"src/node/ext/timeval.h",
"src/node/ext/byte_buffer.cc",
"src/node/ext/call.cc",
"src/node/ext/call_credentials.cc",
"src/node/ext/channel.cc",
"src/node/ext/channel_credentials.cc",
"src/node/ext/completion_queue_async_worker.cc",
"src/node/ext/node_grpc.cc",
"src/node/ext/server.cc",
"src/node/ext/server_credentials.cc",
"src/node/ext/timeval.cc",
"src/node/index.js",
"src/node/src/client.js",
"src/node/src/common.js",
"src/node/src/credentials.js",
"src/node/src/metadata.js",
"src/node/src/server.js",
"include/grpc/grpc_security.h",
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
"include/grpc/grpc.h",
"include/grpc/status.h",
"include/grpc/census.h",
"src/core/security/auth_filters.h",
"src/core/security/base64.h",
"src/core/security/credentials.h",
"src/core/security/handshake.h",
"src/core/security/json_token.h",
"src/core/security/jwt_verifier.h",
"src/core/security/secure_endpoint.h",
"src/core/security/security_connector.h",
"src/core/security/security_context.h",
"src/core/tsi/fake_transport_security.h",
"src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h",
"src/core/tsi/transport_security.h",
"src/core/tsi/transport_security_interface.h",
"src/core/census/grpc_filter.h",
"src/core/channel/channel_args.h",
"src/core/channel/channel_stack.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
"src/core/channel/http_client_filter.h",
"src/core/channel/http_server_filter.h",
"src/core/channel/subchannel_call_holder.h",
"src/core/client_config/client_config.h",
"src/core/client_config/connector.h",
"src/core/client_config/initial_connect_string.h",
"src/core/client_config/lb_policies/pick_first.h",
"src/core/client_config/lb_policies/round_robin.h",
"src/core/client_config/lb_policy.h",
"src/core/client_config/lb_policy_factory.h",
"src/core/client_config/lb_policy_registry.h",
"src/core/client_config/resolver.h",
"src/core/client_config/resolver_factory.h",
"src/core/client_config/resolver_registry.h",
"src/core/client_config/resolvers/dns_resolver.h",
"src/core/client_config/resolvers/sockaddr_resolver.h",
"src/core/client_config/subchannel.h",
"src/core/client_config/subchannel_factory.h",
"src/core/client_config/uri_parser.h",
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
"src/core/iomgr/exec_ctx.h",
"src/core/iomgr/executor.h",
"src/core/iomgr/fd_posix.h",
"src/core/iomgr/iocp_windows.h",
"src/core/iomgr/iomgr.h",
"src/core/iomgr/iomgr_internal.h",
"src/core/iomgr/iomgr_posix.h",
"src/core/iomgr/pollset.h",
"src/core/iomgr/pollset_posix.h",
"src/core/iomgr/pollset_set.h",
"src/core/iomgr/pollset_set_posix.h",
"src/core/iomgr/pollset_set_windows.h",
"src/core/iomgr/pollset_windows.h",
"src/core/iomgr/resolve_address.h",
"src/core/iomgr/sockaddr.h",
"src/core/iomgr/sockaddr_posix.h",
"src/core/iomgr/sockaddr_utils.h",
"src/core/iomgr/sockaddr_win32.h",
"src/core/iomgr/socket_utils_posix.h",
"src/core/iomgr/socket_windows.h",
"src/core/iomgr/tcp_client.h",
"src/core/iomgr/tcp_posix.h",
"src/core/iomgr/tcp_server.h",
"src/core/iomgr/tcp_windows.h",
"src/core/iomgr/time_averaged_stats.h",
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/timer_internal.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
"src/core/iomgr/workqueue_posix.h",
"src/core/iomgr/workqueue_windows.h",
"src/core/json/json.h",
"src/core/json/json_common.h",
"src/core/json/json_reader.h",
"src/core/json/json_writer.h",
"src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h",
"src/core/surface/api_trace.h",
"src/core/surface/call.h",
"src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
"src/core/surface/init.h",
"src/core/surface/server.h",
"src/core/surface/surface_trace.h",
"src/core/transport/byte_stream.h",
"src/core/transport/chttp2/alpn.h",
"src/core/transport/chttp2/bin_encoder.h",
"src/core/transport/chttp2/frame.h",
"src/core/transport/chttp2/frame_data.h",
"src/core/transport/chttp2/frame_goaway.h",
"src/core/transport/chttp2/frame_ping.h",
"src/core/transport/chttp2/frame_rst_stream.h",
"src/core/transport/chttp2/frame_settings.h",
"src/core/transport/chttp2/frame_window_update.h",
"src/core/transport/chttp2/hpack_encoder.h",
"src/core/transport/chttp2/hpack_parser.h",
"src/core/transport/chttp2/hpack_table.h",
"src/core/transport/chttp2/http2_errors.h",
"src/core/transport/chttp2/huffsyms.h",
"src/core/transport/chttp2/incoming_metadata.h",
"src/core/transport/chttp2/internal.h",
"src/core/transport/chttp2/status_conversion.h",
"src/core/transport/chttp2/stream_map.h",
"src/core/transport/chttp2/timeout_encoding.h",
"src/core/transport/chttp2/varint.h",
"src/core/transport/chttp2_transport.h",
"src/core/transport/connectivity_state.h",
"src/core/transport/metadata.h",
"src/core/transport/metadata_batch.h",
"src/core/transport/static_metadata.h",
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/rpc_metric_id.h",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/security/base64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
"src/core/security/credentials_metadata.c",
"src/core/security/credentials_posix.c",
"src/core/security/credentials_win32.c",
"src/core/security/google_default_credentials.c",
"src/core/security/handshake.c",
"src/core/security/json_token.c",
"src/core/security/jwt_verifier.c",
"src/core/security/secure_endpoint.c",
"src/core/security/security_connector.c",
"src/core/security/security_context.c",
"src/core/security/server_auth_filter.c",
"src/core/security/server_secure_chttp2.c",
"src/core/surface/init_secure.c",
"src/core/surface/secure_channel_create.c",
"src/core/tsi/fake_transport_security.c",
"src/core/tsi/ssl_transport_security.c",
"src/core/tsi/transport_security.c",
"src/core/census/grpc_context.c",
"src/core/census/grpc_filter.c",
"src/core/channel/channel_args.c",
"src/core/channel/channel_stack.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
"src/core/channel/http_server_filter.c",
"src/core/channel/subchannel_call_holder.c",
"src/core/client_config/client_config.c",
"src/core/client_config/connector.c",
"src/core/client_config/default_initial_connect_string.c",
"src/core/client_config/initial_connect_string.c",
"src/core/client_config/lb_policies/pick_first.c",
"src/core/client_config/lb_policies/round_robin.c",
"src/core/client_config/lb_policy.c",
"src/core/client_config/lb_policy_factory.c",
"src/core/client_config/lb_policy_registry.c",
"src/core/client_config/resolver.c",
"src/core/client_config/resolver_factory.c",
"src/core/client_config/resolver_registry.c",
"src/core/client_config/resolvers/dns_resolver.c",
"src/core/client_config/resolvers/sockaddr_resolver.c",
"src/core/client_config/subchannel.c",
"src/core/client_config/subchannel_factory.c",
"src/core/client_config/uri_parser.c",
"src/core/compression/algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
"src/core/iomgr/endpoint_pair_windows.c",
"src/core/iomgr/exec_ctx.c",
"src/core/iomgr/executor.c",
"src/core/iomgr/fd_posix.c",
"src/core/iomgr/iocp_windows.c",
"src/core/iomgr/iomgr.c",
"src/core/iomgr/iomgr_posix.c",
"src/core/iomgr/iomgr_windows.c",
"src/core/iomgr/pollset_multipoller_with_epoll.c",
"src/core/iomgr/pollset_multipoller_with_poll_posix.c",
"src/core/iomgr/pollset_posix.c",
"src/core/iomgr/pollset_set_posix.c",
"src/core/iomgr/pollset_set_windows.c",
"src/core/iomgr/pollset_windows.c",
"src/core/iomgr/resolve_address_posix.c",
"src/core/iomgr/resolve_address_windows.c",
"src/core/iomgr/sockaddr_utils.c",
"src/core/iomgr/socket_utils_common_posix.c",
"src/core/iomgr/socket_utils_linux.c",
"src/core/iomgr/socket_utils_posix.c",
"src/core/iomgr/socket_windows.c",
"src/core/iomgr/tcp_client_posix.c",
"src/core/iomgr/tcp_client_windows.c",
"src/core/iomgr/tcp_posix.c",
"src/core/iomgr/tcp_server_posix.c",
"src/core/iomgr/tcp_server_windows.c",
"src/core/iomgr/tcp_windows.c",
"src/core/iomgr/time_averaged_stats.c",
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
"src/core/iomgr/wakeup_fd_posix.c",
"src/core/iomgr/workqueue_posix.c",
"src/core/iomgr/workqueue_windows.c",
"src/core/json/json.c",
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/surface/api_trace.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
"src/core/surface/call.c",
"src/core/surface/call_details.c",
"src/core/surface/call_log_batch.c",
"src/core/surface/channel.c",
"src/core/surface/channel_connectivity.c",
"src/core/surface/channel_create.c",
"src/core/surface/channel_ping.c",
"src/core/surface/completion_queue.c",
"src/core/surface/event_string.c",
"src/core/surface/init.c",
"src/core/surface/lame_client.c",
"src/core/surface/metadata_array.c",
"src/core/surface/server.c",
"src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c",
"src/core/transport/byte_stream.c",
"src/core/transport/chttp2/alpn.c",
"src/core/transport/chttp2/bin_encoder.c",
"src/core/transport/chttp2/frame_data.c",
"src/core/transport/chttp2/frame_goaway.c",
"src/core/transport/chttp2/frame_ping.c",
"src/core/transport/chttp2/frame_rst_stream.c",
"src/core/transport/chttp2/frame_settings.c",
"src/core/transport/chttp2/frame_window_update.c",
"src/core/transport/chttp2/hpack_encoder.c",
"src/core/transport/chttp2/hpack_parser.c",
"src/core/transport/chttp2/hpack_table.c",
"src/core/transport/chttp2/huffsyms.c",
"src/core/transport/chttp2/incoming_metadata.c",
"src/core/transport/chttp2/parsing.c",
"src/core/transport/chttp2/status_conversion.c",
"src/core/transport/chttp2/stream_lists.c",
"src/core/transport/chttp2/stream_map.c",
"src/core/transport/chttp2/timeout_encoding.c",
"src/core/transport/chttp2/varint.c",
"src/core/transport/chttp2/writing.c",
"src/core/transport/chttp2_transport.c",
"src/core/transport/connectivity_state.c",
"src/core/transport/metadata.c",
"src/core/transport/metadata_batch.c",
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
"src/core/census/operation.c",
"src/core/census/tracing.c",
"include/grpc/support/alloc.h",
"include/grpc/support/atm.h",
"include/grpc/support/atm_gcc_atomic.h",
"include/grpc/support/atm_gcc_sync.h",
"include/grpc/support/atm_win32.h",
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
"include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_win32.h",
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
"include/grpc/support/sync_win32.h",
"include/grpc/support/thd.h",
"include/grpc/support/time.h",
"include/grpc/support/tls.h",
"include/grpc/support/tls_gcc.h",
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/profiling/timers.h",
"src/core/support/block_annotate.h",
"src/core/support/env.h",
"src/core/support/file.h",
"src/core/support/murmur_hash.h",
"src/core/support/stack_lockfree.h",
"src/core/support/string.h",
"src/core/support/string_win32.h",
"src/core/support/thd_internal.h",
"src/core/support/time_precise.h",
"src/core/profiling/basic_timers.c",
"src/core/profiling/stap_timers.c",
"src/core/support/alloc.c",
"src/core/support/avl.c",
"src/core/support/cmdline.c",
"src/core/support/cpu_iphone.c",
"src/core/support/cpu_linux.c",
"src/core/support/cpu_posix.c",
"src/core/support/cpu_windows.c",
"src/core/support/env_linux.c",
"src/core/support/env_posix.c",
"src/core/support/env_win32.c",
"src/core/support/file.c",
"src/core/support/file_posix.c",
"src/core/support/file_win32.c",
"src/core/support/histogram.c",
"src/core/support/host_port.c",
"src/core/support/log.c",
"src/core/support/log_android.c",
"src/core/support/log_linux.c",
"src/core/support/log_posix.c",
"src/core/support/log_win32.c",
"src/core/support/murmur_hash.c",
"src/core/support/slice.c",
"src/core/support/slice_buffer.c",
"src/core/support/stack_lockfree.c",
"src/core/support/string.c",
"src/core/support/string_posix.c",
"src/core/support/string_win32.c",
"src/core/support/subprocess_posix.c",
"src/core/support/sync.c",
"src/core/support/sync_posix.c",
"src/core/support/sync_win32.c",
"src/core/support/thd.c",
"src/core/support/thd_posix.c",
"src/core/support/thd_win32.c",
"src/core/support/time.c",
"src/core/support/time_posix.c",
"src/core/support/time_precise.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
"binding.gyp" "binding.gyp"
], ],
"main": "src/node/index.js", "main": "src/node/index.js",

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -37,6 +37,7 @@
#include <string.h> #include <string.h>
#include <grpc/compression.h> #include <grpc/compression.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 <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -562,12 +563,16 @@ static int prepare_application_metadata(grpc_call *call, int count,
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data)); GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
l->md = grpc_mdelem_from_string_and_buffer( l->md = grpc_mdelem_from_string_and_buffer(
md->key, (const uint8_t *)md->value, md->value_length); md->key, (const uint8_t *)md->value, md->value_length);
if (!grpc_mdstr_is_legal_header(l->md->key)) { if (!grpc_header_key_is_legal(grpc_mdstr_as_c_string(l->md->key),
GRPC_MDSTR_LENGTH(l->md->key))) {
gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s",
grpc_mdstr_as_c_string(l->md->key)); grpc_mdstr_as_c_string(l->md->key));
return 0; return 0;
} else if (!grpc_mdstr_is_bin_suffixed(l->md->key) && } else if (!grpc_is_binary_header(grpc_mdstr_as_c_string(l->md->key),
!grpc_mdstr_is_legal_nonbin_header(l->md->value)) { GRPC_MDSTR_LENGTH(l->md->key)) &&
!grpc_header_nonbin_value_is_legal(
grpc_mdstr_as_c_string(l->md->value),
GRPC_MDSTR_LENGTH(l->md->value))) {
gpr_log(GPR_ERROR, "attempt to send invalid metadata value"); gpr_log(GPR_ERROR, "attempt to send invalid metadata value");
return 0; return 0;
} }

@ -0,0 +1,73 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdlib.h>
#include <string.h>
#include <grpc/support/port_platform.h>
static int conforms_to(const char *s, size_t len, const uint8_t *legal_bits) {
const char *p = s;
const char *e = s + len;
for (; p != e; p++) {
int idx = *p;
int byte = idx / 8;
int bit = idx % 8;
if ((legal_bits[byte] & (1 << bit)) == 0) return 0;
}
return 1;
}
int grpc_header_key_is_legal(const char *key, size_t length) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xff, 0x03, 0x00, 0x00, 0x00,
0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
if (length == 0) {
return 0;
}
return conforms_to(key, length, legal_header_bits);
}
int grpc_header_nonbin_value_is_legal(const char *value, size_t length) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
return conforms_to(value, length, legal_header_bits);
}
int grpc_is_binary_header(const char *key, size_t length) {
if (length < 5) return 0;
return 0 == memcmp(key + length - 4, "-bin", 4);
}

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -283,8 +283,3 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
GPR_ASSERT(in == GPR_SLICE_END_PTR(input)); GPR_ASSERT(in == GPR_SLICE_END_PTR(input));
return output; return output;
} }
int grpc_is_binary_header(const char *key, size_t length) {
if (length < 5) return 0;
return 0 == memcmp(key + length - 4, "-bin", 4);
}

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -51,6 +51,4 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input);
return y; */ return y; */
gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input); gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input);
int grpc_is_binary_header(const char *key, size_t length);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H */

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,6 +36,11 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
/* This is here for grpc_is_binary_header
* TODO(murgatroid99): Remove this
*/
#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 <grpc/support/useful.h> #include <grpc/support/useful.h>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,6 +38,11 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
/* This is here for grpc_is_binary_header
* TODO(murgatroid99): Remove this
*/
#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 <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -688,37 +688,3 @@ gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *gs) {
gpr_mu_unlock(&shard->mu); gpr_mu_unlock(&shard->mu);
return slice; return slice;
} }
static int conforms_to(grpc_mdstr *s, const uint8_t *legal_bits) {
const uint8_t *p = GPR_SLICE_START_PTR(s->slice);
const uint8_t *e = GPR_SLICE_END_PTR(s->slice);
for (; p != e; p++) {
int idx = *p;
int byte = idx / 8;
int bit = idx % 8;
if ((legal_bits[byte] & (1 << bit)) == 0) return 0;
}
return 1;
}
int grpc_mdstr_is_legal_header(grpc_mdstr *s) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00,
0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
return conforms_to(s, legal_header_bits);
}
int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
return conforms_to(s, legal_header_bits);
}
int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s) {
/* TODO(ctiller): consider caching this */
return grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(s->slice),
GPR_SLICE_LENGTH(s->slice));
}

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -142,6 +142,8 @@ void grpc_mdelem_unref(grpc_mdelem *md);
Does not promise that the returned string has no embedded nulls however. */ Does not promise that the returned string has no embedded nulls however. */
const char *grpc_mdstr_as_c_string(grpc_mdstr *s); const char *grpc_mdstr_as_c_string(grpc_mdstr *s);
#define GRPC_MDSTR_LENGTH(s) (GPR_SLICE_LENGTH(s->slice))
int grpc_mdstr_is_legal_header(grpc_mdstr *s); int grpc_mdstr_is_legal_header(grpc_mdstr *s);
int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s); int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s);
int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s); int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s);

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -95,10 +95,6 @@ Local<Value> nanErrorWithCode(const char *msg, grpc_call_error code) {
return scope.Escape(err); return scope.Escape(err);
} }
bool EndsWith(const char *str, const char *substr) {
return strcmp(str+strlen(str)-strlen(substr), substr) == 0;
}
bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array, bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array,
shared_ptr<Resources> resources) { shared_ptr<Resources> resources) {
HandleScope scope; HandleScope scope;
@ -126,7 +122,7 @@ bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array,
grpc_metadata *current = &array->metadata[array->count]; grpc_metadata *current = &array->metadata[array->count];
current->key = **utf8_key; current->key = **utf8_key;
// Only allow binary headers for "-bin" keys // Only allow binary headers for "-bin" keys
if (EndsWith(current->key, "-bin")) { if (grpc_is_binary_header(current->key, strlen(current->key))) {
if (::node::Buffer::HasInstance(value)) { if (::node::Buffer::HasInstance(value)) {
current->value = ::node::Buffer::Data(value); current->value = ::node::Buffer::Data(value);
current->value_length = ::node::Buffer::Length(value); current->value_length = ::node::Buffer::Length(value);
@ -180,7 +176,7 @@ Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
} else { } else {
array = Local<Array>::Cast(maybe_array.ToLocalChecked()); array = Local<Array>::Cast(maybe_array.ToLocalChecked());
} }
if (EndsWith(elem->key, "-bin")) { if (grpc_is_binary_header(elem->key, strlen(elem->key))) {
Nan::Set(array, index_map[elem->key], Nan::Set(array, index_map[elem->key],
MakeFastBuffer( MakeFastBuffer(
Nan::CopyBuffer(elem->value, Nan::CopyBuffer(elem->value,

@ -32,6 +32,8 @@
*/ */
#include <node.h> #include <node.h>
#include <nan.h>
#include <uv.h>
#include "grpc/grpc.h" #include "grpc/grpc.h"
#include "grpc/grpc_security.h" #include "grpc/grpc_security.h"

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include "completion_queue_async_worker.h" #include "completion_queue_async_worker.h"
#include "server_credentials.h" #include "server_credentials.h"
using v8::FunctionTemplate;
using v8::Local; using v8::Local;
using v8::Value; using v8::Value;
using v8::Object; using v8::Object;
@ -230,6 +231,40 @@ void InitWriteFlags(Local<Object> exports) {
Nan::Set(write_flags, Nan::New("NO_COMPRESS").ToLocalChecked(), NO_COMPRESS); Nan::Set(write_flags, Nan::New("NO_COMPRESS").ToLocalChecked(), NO_COMPRESS);
} }
NAN_METHOD(MetadataKeyIsLegal) {
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(
"headerKeyIsLegal's argument must be a string");
}
Local<String> key = Nan::To<String>(info[0]).ToLocalChecked();
char *key_str = *Nan::Utf8String(key);
info.GetReturnValue().Set(static_cast<bool>(
grpc_header_key_is_legal(key_str, static_cast<size_t>(key->Length()))));
}
NAN_METHOD(MetadataNonbinValueIsLegal) {
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(
"metadataNonbinValueIsLegal's argument must be a string");
}
Local<String> value = Nan::To<String>(info[0]).ToLocalChecked();
char *value_str = *Nan::Utf8String(value);
info.GetReturnValue().Set(static_cast<bool>(
grpc_header_nonbin_value_is_legal(
value_str, static_cast<size_t>(value->Length()))));
}
NAN_METHOD(MetadataKeyIsBinary) {
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(
"metadataKeyIsLegal's argument must be a string");
}
Local<String> key = Nan::To<String>(info[0]).ToLocalChecked();
char *key_str = *Nan::Utf8String(key);
info.GetReturnValue().Set(static_cast<bool>(
grpc_is_binary_header(key_str, static_cast<size_t>(key->Length()))));
}
void init(Local<Object> exports) { void init(Local<Object> exports) {
Nan::HandleScope scope; Nan::HandleScope scope;
grpc_init(); grpc_init();
@ -247,6 +282,19 @@ void init(Local<Object> exports) {
grpc::node::Server::Init(exports); grpc::node::Server::Init(exports);
grpc::node::CompletionQueueAsyncWorker::Init(exports); grpc::node::CompletionQueueAsyncWorker::Init(exports);
grpc::node::ServerCredentials::Init(exports); grpc::node::ServerCredentials::Init(exports);
// Attach a few utility functions directly to the module
Nan::Set(exports, Nan::New("metadataKeyIsLegal").ToLocalChecked(),
Nan::GetFunction(
Nan::New<FunctionTemplate>(MetadataKeyIsLegal)).ToLocalChecked());
Nan::Set(exports, Nan::New("metadataNonbinValueIsLegal").ToLocalChecked(),
Nan::GetFunction(
Nan::New<FunctionTemplate>(MetadataNonbinValueIsLegal)
).ToLocalChecked());
Nan::Set(exports, Nan::New("metadataKeyIsBinary").ToLocalChecked(),
Nan::GetFunction(
Nan::New<FunctionTemplate>(MetadataKeyIsBinary)
).ToLocalChecked());
} }
NODE_MODULE(grpc_node, init) NODE_MODULE(grpc_node, init)

@ -46,7 +46,7 @@ gpr_timespec MillisecondsToTimespec(double millis) {
} else if (millis == -std::numeric_limits<double>::infinity()) { } else if (millis == -std::numeric_limits<double>::infinity()) {
return gpr_inf_past(GPR_CLOCK_REALTIME); return gpr_inf_past(GPR_CLOCK_REALTIME);
} else { } else {
return gpr_time_from_micros(static_cast<int64_t>(millis * 1000), return gpr_time_from_micros(static_cast<long>(millis * 1000),
GPR_CLOCK_REALTIME); GPR_CLOCK_REALTIME);
} }
} }

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,8 +36,8 @@
var _ = require('lodash'); var _ = require('lodash');
/** /**
* This class represents a queue of callbacks that must happen sequentially, each * This class represents a queue of callbacks that must happen sequentially,
* with a specific delay after the previous event. * each with a specific delay after the previous event.
*/ */
function AsyncDelayQueue() { function AsyncDelayQueue() {
this.queue = []; this.queue = [];

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -125,7 +125,7 @@ exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service) {
var prefix = '/' + fullyQualifiedName(service) + '/'; var prefix = '/' + fullyQualifiedName(service) + '/';
return _.object(_.map(service.children, function(method) { return _.object(_.map(service.children, function(method) {
return [_.camelCase(method.name), { return [_.camelCase(method.name), {
path: prefix + _.capitalize(method.name), path: prefix + method.name,
requestStream: method.requestStream, requestStream: method.requestStream,
responseStream: method.responseStream, responseStream: method.responseStream,
requestSerialize: serializeCls(method.resolvedRequestType.build()), requestSerialize: serializeCls(method.resolvedRequestType.build()),

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,6 +49,8 @@
var _ = require('lodash'); var _ = require('lodash');
var grpc = require('bindings')('grpc_node');
/** /**
* Class for storing metadata. Keys are normalized to lowercase ASCII. * Class for storing metadata. Keys are normalized to lowercase ASCII.
* @constructor * @constructor
@ -58,15 +60,16 @@ function Metadata() {
} }
function normalizeKey(key) { function normalizeKey(key) {
if (!(/^[A-Za-z\d_-]+$/.test(key))) { key = key.toLowerCase();
throw new Error('Metadata keys must be nonempty strings containing only ' + if (grpc.metadataKeyIsLegal(key)) {
'alphanumeric characters and hyphens'); return key;
} else {
throw new Error('Metadata key contains illegal characters');
} }
return key.toLowerCase();
} }
function validate(key, value) { function validate(key, value) {
if (_.endsWith(key, '-bin')) { if (grpc.metadataKeyIsBinary(key)) {
if (!(value instanceof Buffer)) { if (!(value instanceof Buffer)) {
throw new Error('keys that end with \'-bin\' must have Buffer values'); throw new Error('keys that end with \'-bin\' must have Buffer values');
} }
@ -75,9 +78,8 @@ function validate(key, value) {
throw new Error( throw new Error(
'keys that don\'t end with \'-bin\' must have String values'); 'keys that don\'t end with \'-bin\' must have String values');
} }
if (!(/^[\x20-\x7E]*$/.test(value))) { if (!grpc.metadataNonbinValueIsLegal(value)) {
throw new Error('Metadata string values can only contain printable ' + throw new Error('Metadata string value contains illegal characters');
'ASCII characters and space');
} }
} }
} }

@ -241,11 +241,11 @@ DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.")
@protocol GRPCRequestHeaders <NSObject> @protocol GRPCRequestHeaders <NSObject>
@property(nonatomic, readonly) NSUInteger count; @property(nonatomic, readonly) NSUInteger count;
- (id)objectForKeyedSubscript:(NSString *)key; - (id)objectForKeyedSubscript:(id)key;
- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key; - (void)setObject:(id)obj forKeyedSubscript:(id)key;
- (void)removeAllObjects; - (void)removeAllObjects;
- (void)removeObjectForKey:(NSString *)key; - (void)removeObjectForKey:(id)key;
@end @end
#pragma clang diagnostic push #pragma clang diagnostic push

@ -107,6 +107,7 @@
633BFFBF1B950B210007E424 /* Frameworks */, 633BFFBF1B950B210007E424 /* Frameworks */,
633BFFC01B950B210007E424 /* Resources */, 633BFFC01B950B210007E424 /* Resources */,
AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */, AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */,
A1738A987353B0BF2C64F0F7 /* Embed Pods Frameworks */,
); );
buildRules = ( buildRules = (
); );
@ -123,6 +124,7 @@
633BFFBA1B950B210007E424 /* Project object */ = { 633BFFBA1B950B210007E424 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0640; LastUpgradeCheck = 0640;
ORGANIZATIONNAME = gRPC; ORGANIZATIONNAME = gRPC;
TargetAttributes = { TargetAttributes = {
@ -177,6 +179,21 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
A1738A987353B0BF2C64F0F7 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */ = { AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -310,7 +327,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
USER_HEADER_SEARCH_PATHS = "Pods/**"; USER_HEADER_SEARCH_PATHS = "";
}; };
name = Debug; name = Debug;
}; };
@ -323,7 +340,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
USER_HEADER_SEARCH_PATHS = "Pods/**"; USER_HEADER_SEARCH_PATHS = "";
}; };
name = Release; name = Release;
}; };

@ -1,5 +1,5 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -36,21 +36,36 @@ import os
import re import re
import sys import sys
def update_deps(key, proto_filename, deps, is_trans, visited):
if not proto_filename in visited:
visited.append(proto_filename)
with open(proto_filename) as inp:
for line in inp:
imp = re.search(r'import "([^"]*)"', line)
if not imp: continue
imp_proto = imp.group(1)
if key not in deps: deps[key] = []
deps[key].append(imp_proto[:-6])
if is_trans:
update_deps(key, imp_proto, deps, is_trans, visited)
def main(): def main():
proto_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
os.chdir(os.path.join(proto_dir, '../..'))
deps = {} deps = {}
for root, dirs, files in os.walk(os.path.dirname(sys.argv[0])): deps_trans = {}
for root, dirs, files in os.walk('src/proto'):
for f in files: for f in files:
if f[-6:] != '.proto': continue if f[-6:] != '.proto': continue
look_at = os.path.join(root, f) look_at = os.path.join(root, f)
with open(look_at) as inp: deps_for = look_at[:-6]
for line in inp: update_deps(deps_for, look_at, deps, False, []) # First level deps
imp = re.search(r'import "([^"]*)"', line) update_deps(deps_for, look_at, deps_trans, True, []) # Transitive deps
if not imp: continue
if look_at[:-6] not in deps: deps[look_at[:-6]] = []
deps[look_at[:-6]].append(imp.group(1)[:-6])
json = { json = {
'proto_deps': deps 'proto_deps': deps,
'proto_transitive_deps': deps_trans
} }
print yaml.dump(json) print yaml.dump(json)

@ -1,5 +1,5 @@
// Copyright 2015, Google Inc. // Copyright 2015-2016, Google Inc.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without

@ -1,5 +1,5 @@
// Copyright 2015, Google Inc. // Copyright 2015-2016, Google Inc.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without

@ -188,6 +188,7 @@ CORE_SOURCE_FILES = [
'src/core/surface/server.c', 'src/core/surface/server.c',
'src/core/surface/server_chttp2.c', 'src/core/surface/server_chttp2.c',
'src/core/surface/server_create.c', 'src/core/surface/server_create.c',
'src/core/surface/validate_metadata.c',
'src/core/surface/version.c', 'src/core/surface/version.c',
'src/core/transport/byte_stream.c', 'src/core/transport/byte_stream.c',
'src/core/transport/chttp2/alpn.c', 'src/core/transport/chttp2/alpn.c',

@ -1,6 +0,0 @@
-I.
-Ipb
--backtrace
--require spec_helper
--format documentation
--color

@ -54,54 +54,31 @@ LIB_DIRS = [
LIBDIR LIBDIR
] ]
def check_grpc_root
grpc_root = ENV['GRPC_ROOT']
if grpc_root.nil?
r = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
grpc_root = r if File.exist?(File.join(r, 'include/grpc/grpc.h'))
end
grpc_root
end
grpc_pkg_config = system('pkg-config --exists grpc')
if grpc_pkg_config
$CFLAGS << ' ' + `pkg-config --static --cflags grpc`.strip + ' '
$LDFLAGS << ' ' + `pkg-config --static --libs grpc`.strip + ' '
else
dir_config('grpc', HEADER_DIRS, LIB_DIRS)
fail 'libdl not found' unless have_library('dl', 'dlopen') fail 'libdl not found' unless have_library('dl', 'dlopen')
fail 'zlib not found' unless have_library('z', 'inflate') fail 'zlib not found' unless have_library('z', 'inflate')
begin
fail 'Fail' unless have_library('gpr', 'gpr_now')
fail 'Fail' unless have_library('grpc', 'grpc_channel_destroy')
rescue
# Check to see if GRPC_ROOT is defined or available
grpc_root = check_grpc_root
# Stop if there is still no grpc_root grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
exit 1 if grpc_root.nil?
grpc_config = ENV['GRPC_CONFIG'] || 'opt' grpc_config = ENV['GRPC_CONFIG'] || 'opt'
if ENV.key?('GRPC_LIB_DIR') if ENV.key?('GRPC_LIB_DIR')
grpc_lib_dir = File.join(grpc_root, ENV['GRPC_LIB_DIR']) grpc_lib_dir = File.join(grpc_root, ENV['GRPC_LIB_DIR'])
else else
grpc_lib_dir = File.join(File.join(grpc_root, 'libs'), grpc_config) grpc_lib_dir = File.join(File.join(grpc_root, 'libs'), grpc_config)
end end
unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a')) unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a'))
print "Building internal gRPC\n" print "Building internal gRPC\n"
system("make -C #{grpc_root} static_c CONFIG=#{grpc_config}") system("make -C #{grpc_root} static_c CONFIG=#{grpc_config}")
end end
$CFLAGS << ' -I' + File.join(grpc_root, 'include') $CFLAGS << ' -I' + File.join(grpc_root, 'include')
$LDFLAGS << ' -L' + grpc_lib_dir $LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a')
$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgpr.a')
if grpc_config == 'gcov' if grpc_config == 'gcov'
$CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage' $CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage'
$LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic' $LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic'
end end
raise 'gpr not found' unless have_library('gpr', 'gpr_now')
raise 'grpc not found' unless have_library('grpc', 'grpc_channel_destroy')
end
end
$CFLAGS << ' -std=c99 ' $CFLAGS << ' -std=c99 '
$CFLAGS << ' -Wall ' $CFLAGS << ' -Wall '
@ -109,4 +86,7 @@ $CFLAGS << ' -Wextra '
$CFLAGS << ' -pedantic ' $CFLAGS << ' -pedantic '
$CFLAGS << ' -Werror ' $CFLAGS << ' -Werror '
$LDFLAGS << ' -lssl '
$LDFLAGS << ' -lcrypto '
create_makefile('grpc/grpc') create_makefile('grpc/grpc')

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -310,33 +310,61 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
grpc_metadata_array *md_ary = NULL; grpc_metadata_array *md_ary = NULL;
long array_length; long array_length;
long i; long i;
char *key_str;
size_t key_len;
char *value_str;
size_t value_len;
if (TYPE(key) == T_SYMBOL) {
key_str = (char *)rb_id2name(SYM2ID(key));
key_len = strlen(key_str);
} else { /* StringValueCStr does all other type exclusions for us */
key_str = StringValueCStr(key);
key_len = RSTRING_LEN(key);
}
if (!grpc_header_key_is_legal(key_str, key_len)) {
rb_raise(rb_eArgError,
"'%s' is an invalid header key, must match [a-z0-9-_.]+",
key_str);
return ST_STOP;
}
/* Construct a metadata object from key and value and add it */ /* Construct a metadata object from key and value and add it */
TypedData_Get_Struct(md_ary_obj, grpc_metadata_array, TypedData_Get_Struct(md_ary_obj, grpc_metadata_array,
&grpc_rb_md_ary_data_type, md_ary); &grpc_rb_md_ary_data_type, md_ary);
if (TYPE(val) == T_ARRAY) { if (TYPE(val) == T_ARRAY) {
/* If the value is an array, add capacity for each value in the array */
array_length = RARRAY_LEN(val); array_length = RARRAY_LEN(val);
/* If the value is an array, add capacity for each value in the array */
for (i = 0; i < array_length; i++) { for (i = 0; i < array_length; i++) {
if (TYPE(key) == T_SYMBOL) { value_str = RSTRING_PTR(rb_ary_entry(val, i));
md_ary->metadata[md_ary->count].key = (char *)rb_id2name(SYM2ID(key)); value_len = RSTRING_LEN(rb_ary_entry(val, i));
} else { /* StringValueCStr does all other type exclusions for us */ if (!grpc_is_binary_header(key_str, key_len) &&
md_ary->metadata[md_ary->count].key = StringValueCStr(key); !grpc_header_nonbin_value_is_legal(value_str, value_len)) {
// The value has invalid characters
rb_raise(rb_eArgError,
"Header value '%s' has invalid characters", value_str);
return ST_STOP;
} }
md_ary->metadata[md_ary->count].value = RSTRING_PTR(rb_ary_entry(val, i)); md_ary->metadata[md_ary->count].key = key_str;
md_ary->metadata[md_ary->count].value_length = md_ary->metadata[md_ary->count].value = value_str;
RSTRING_LEN(rb_ary_entry(val, i)); md_ary->metadata[md_ary->count].value_length = value_len;
md_ary->count += 1; md_ary->count += 1;
} }
} else { } else {
if (TYPE(key) == T_SYMBOL) { value_str = RSTRING_PTR(val);
md_ary->metadata[md_ary->count].key = (char *)rb_id2name(SYM2ID(key)); value_len = RSTRING_LEN(val);
} else { /* StringValueCStr does all other type exclusions for us */ if (!grpc_is_binary_header(key_str, key_len) &&
md_ary->metadata[md_ary->count].key = StringValueCStr(key); !grpc_header_nonbin_value_is_legal(value_str, value_len)) {
// The value has invalid characters
rb_raise(rb_eArgError,
"Header value '%s' has invalid characters", value_str);
return ST_STOP;
} }
md_ary->metadata[md_ary->count].value = RSTRING_PTR(val); md_ary->metadata[md_ary->count].key = key_str;
md_ary->metadata[md_ary->count].value_length = RSTRING_LEN(val); md_ary->metadata[md_ary->count].value = value_str;
md_ary->metadata[md_ary->count].value_length = value_len;
md_ary->count += 1; md_ary->count += 1;
} }

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,8 +38,10 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include "rb_call.h" #include "rb_call.h"
#include "rb_event_thread.h"
#include "rb_grpc.h" #include "rb_grpc.h"
/* grpc_rb_cCallCredentials is the ruby class that proxies /* grpc_rb_cCallCredentials is the ruby class that proxies
@ -87,7 +89,7 @@ static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
return result; return result;
} }
static void *grpc_rb_call_credentials_callback_with_gil(void *param) { static void grpc_rb_call_credentials_callback_with_gil(void *param) {
callback_params *const params = (callback_params *)param; callback_params *const params = (callback_params *)param;
VALUE auth_uri = rb_str_new_cstr(params->context.service_url); VALUE auth_uri = rb_str_new_cstr(params->context.service_url);
/* Pass the arguments to the proc in a hash, which currently only has they key /* Pass the arguments to the proc in a hash, which currently only has they key
@ -113,21 +115,20 @@ static void *grpc_rb_call_credentials_callback_with_gil(void *param) {
params->callback(params->user_data, md_ary.metadata, md_ary.count, status, params->callback(params->user_data, md_ary.metadata, md_ary.count, status,
error_details); error_details);
grpc_metadata_array_destroy(&md_ary); grpc_metadata_array_destroy(&md_ary);
gpr_free(params);
return NULL;
} }
static void grpc_rb_call_credentials_plugin_get_metadata( static void grpc_rb_call_credentials_plugin_get_metadata(
void *state, grpc_auth_metadata_context context, void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void *user_data) { grpc_credentials_plugin_metadata_cb cb, void *user_data) {
callback_params params; callback_params *params = gpr_malloc(sizeof(callback_params));
params.get_metadata = (VALUE)state; params->get_metadata = (VALUE)state;
params.context = context; params->context = context;
params.user_data = user_data; params->user_data = user_data;
params.callback = cb; params->callback = cb;
rb_thread_call_with_gvl(grpc_rb_call_credentials_callback_with_gil, grpc_rb_event_queue_enqueue(grpc_rb_call_credentials_callback_with_gil,
(void*)(&params)); (void*)(params));
} }
static void grpc_rb_call_credentials_plugin_destroy(void *state) { static void grpc_rb_call_credentials_plugin_destroy(void *state) {
@ -300,6 +301,8 @@ void Init_grpc_call_credentials() {
grpc_rb_call_credentials_compose, -1); grpc_rb_call_credentials_compose, -1);
id_callback = rb_intern("__callback"); id_callback = rb_intern("__callback");
grpc_rb_event_queue_thread_start();
} }
/* Gets the wrapped grpc_call_credentials from the ruby wrapper */ /* Gets the wrapped grpc_call_credentials from the ruby wrapper */

@ -59,6 +59,9 @@ static ID id_target;
* GCed before the channel */ * GCed before the channel */
static ID id_cqueue; static ID id_cqueue;
/* id_insecure_channel is used to indicate that a channel is insecure */
static VALUE id_insecure_channel;
/* grpc_rb_cChannel is the ruby class that proxies grpc_channel. */ /* grpc_rb_cChannel is the ruby class that proxies grpc_channel. */
static VALUE grpc_rb_cChannel = Qnil; static VALUE grpc_rb_cChannel = Qnil;
@ -126,7 +129,8 @@ static VALUE grpc_rb_channel_alloc(VALUE cls) {
/* /*
call-seq: call-seq:
insecure_channel = Channel:new("myhost:8080", {'arg1': 'value1'}) insecure_channel = Channel:new("myhost:8080", {'arg1': 'value1'},
:this_channel_is_insecure)
creds = ... creds = ...
secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds) secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds)
@ -142,13 +146,18 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
grpc_channel_args args; grpc_channel_args args;
MEMZERO(&args, grpc_channel_args, 1); MEMZERO(&args, grpc_channel_args, 1);
/* "21" == 2 mandatory args, 1 (credentials) is optional */ /* "3" == 3 mandatory args */
rb_scan_args(argc, argv, "21", &target, &channel_args, &credentials); rb_scan_args(argc, argv, "3", &target, &channel_args, &credentials);
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
target_chars = StringValueCStr(target); target_chars = StringValueCStr(target);
grpc_rb_hash_convert_to_channel_args(channel_args, &args); grpc_rb_hash_convert_to_channel_args(channel_args, &args);
if (credentials == Qnil) { if (TYPE(credentials) == T_SYMBOL) {
if (id_insecure_channel != SYM2ID(credentials)) {
rb_raise(rb_eTypeError,
"bad creds symbol, want :this_channel_is_insecure");
return Qnil;
}
ch = grpc_insecure_channel_create(target_chars, &args, NULL); ch = grpc_insecure_channel_create(target_chars, &args, NULL);
} else { } else {
creds = grpc_rb_get_wrapped_channel_credentials(credentials); creds = grpc_rb_get_wrapped_channel_credentials(credentials);
@ -408,6 +417,7 @@ void Init_grpc_channel() {
ID2SYM(rb_intern(GRPC_ARG_MAX_CONCURRENT_STREAMS))); ID2SYM(rb_intern(GRPC_ARG_MAX_CONCURRENT_STREAMS)));
rb_define_const(grpc_rb_cChannel, "MAX_MESSAGE_LENGTH", rb_define_const(grpc_rb_cChannel, "MAX_MESSAGE_LENGTH",
ID2SYM(rb_intern(GRPC_ARG_MAX_MESSAGE_LENGTH))); ID2SYM(rb_intern(GRPC_ARG_MAX_MESSAGE_LENGTH)));
id_insecure_channel = rb_intern("this_channel_is_insecure");
Init_grpc_propagate_masks(); Init_grpc_propagate_masks();
Init_grpc_connectivity_states(); Init_grpc_connectivity_states();
} }

@ -0,0 +1,153 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "rb_event_thread.h"
#include <stdbool.h>
#include <ruby/ruby.h>
#include <ruby/thread.h>
#include <grpc/support/alloc.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include <grpc/support/log.h>
typedef struct grpc_rb_event {
// callback will be called with argument while holding the GVL
void (*callback)(void*);
void *argument;
struct grpc_rb_event *next;
} grpc_rb_event;
typedef struct grpc_rb_event_queue {
grpc_rb_event *head;
grpc_rb_event *tail;
gpr_mu mu;
gpr_cv cv;
// Indicates that the thread should stop waiting
bool abort;
} grpc_rb_event_queue;
static grpc_rb_event_queue event_queue;
void grpc_rb_event_queue_enqueue(void (*callback)(void*),
void *argument) {
grpc_rb_event *event = gpr_malloc(sizeof(grpc_rb_event));
event->callback = callback;
event->argument = argument;
event->next = NULL;
gpr_mu_lock(&event_queue.mu);
if (event_queue.tail == NULL) {
event_queue.head = event_queue.tail = event;
} else {
event_queue.tail->next = event;
event_queue.tail = event;
}
gpr_cv_signal(&event_queue.cv);
gpr_mu_unlock(&event_queue.mu);
}
static grpc_rb_event *grpc_rb_event_queue_dequeue() {
grpc_rb_event *event;
if (event_queue.head == NULL) {
event = NULL;
} else {
event = event_queue.head;
if (event_queue.head->next == NULL) {
event_queue.head = event_queue.tail = NULL;
} else {
event_queue.head = event_queue.head->next;
}
}
return event;
}
static void grpc_rb_event_queue_destroy() {
gpr_mu_destroy(&event_queue.mu);
gpr_cv_destroy(&event_queue.cv);
}
static void *grpc_rb_wait_for_event_no_gil(void *param) {
grpc_rb_event *event = NULL;
gpr_mu_lock(&event_queue.mu);
while ((event = grpc_rb_event_queue_dequeue()) == NULL) {
gpr_cv_wait(&event_queue.cv,
&event_queue.mu,
gpr_inf_future(GPR_CLOCK_REALTIME));
if (event_queue.abort) {
gpr_mu_unlock(&event_queue.mu);
return NULL;
}
}
gpr_mu_unlock(&event_queue.mu);
return event;
}
static void grpc_rb_event_unblocking_func(void *arg) {
gpr_mu_lock(&event_queue.mu);
event_queue.abort = true;
gpr_cv_signal(&event_queue.cv);
gpr_mu_unlock(&event_queue.mu);
}
/* This is the implementation of the thread that handles auth metadata plugin
* events */
static VALUE grpc_rb_event_thread(VALUE arg) {
grpc_rb_event *event;
while(true) {
event = (grpc_rb_event*)rb_thread_call_without_gvl(
grpc_rb_wait_for_event_no_gil, NULL,
grpc_rb_event_unblocking_func, NULL);
if (event == NULL) {
// Indicates that the thread needs to shut down
break;
} else {
event->callback(event->argument);
gpr_free(event);
}
}
grpc_rb_event_queue_destroy();
return Qnil;
}
void grpc_rb_event_queue_thread_start() {
event_queue.head = event_queue.tail = NULL;
event_queue.abort = false;
gpr_mu_init(&event_queue.mu);
gpr_cv_init(&event_queue.cv);
rb_thread_create(grpc_rb_event_thread, NULL);
}

@ -0,0 +1,37 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
void grpc_rb_event_queue_thread_start();
void grpc_rb_event_queue_enqueue(void (*callback)(void*),
void *argument);

@ -1,45 +0,0 @@
# -*- ruby -*-
# encoding: utf-8
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'grpc/version'
Gem::Specification.new do |s|
s.name = 'grpc'
s.version = GRPC::VERSION
s.authors = ['gRPC Authors']
s.email = 'temiola@google.com'
s.homepage = 'https://github.com/google/grpc/tree/master/src/ruby'
s.summary = 'GRPC system in Ruby'
s.description = 'Send RPCs from Ruby using GRPC'
s.license = 'BSD-3-Clause'
s.required_ruby_version = '>= 2.0.0'
s.requirements << 'libgrpc ~> 0.11.0 needs to be installed'
s.files = %w( Rakefile )
s.files += Dir.glob('bin/**/*')
s.files += Dir.glob('ext/**/*')
s.files += Dir.glob('lib/**/*')
s.files += Dir.glob('pb/**/*')
s.test_files = Dir.glob('spec/**/*')
%w(math noproto).each do |b|
s.executables += ["#{b}_client.rb", "#{b}_server.rb"]
end
s.executables += %w(grpc_ruby_interop_client grpc_ruby_interop_server)
s.require_paths = %w( bin lib pb )
s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1'
s.add_dependency 'googleauth', '~> 0.4'
s.add_development_dependency 'bundler', '~> 1.9'
s.add_development_dependency 'logging', '~> 2.0'
s.add_development_dependency 'simplecov', '~> 0.9'
s.add_development_dependency 'rake', '~> 10.4'
s.add_development_dependency 'rake-compiler', '~> 0.9'
s.add_development_dependency 'rspec', '~> 3.2'
s.add_development_dependency 'rubocop', '~> 0.30.0'
s.add_development_dependency 'signet', '~>0.6.0'
s.extensions = %w(ext/grpc/extconf.rb)
end

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -27,6 +27,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ssl_roots_path = File.expand_path('../../../../etc/roots.pem', __FILE__)
unless ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH']
ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'] = ssl_roots_path
end
require 'grpc/errors' require 'grpc/errors'
require 'grpc/grpc' require 'grpc/grpc'
require 'grpc/logconfig' require 'grpc/logconfig'

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -50,9 +50,8 @@ module GRPC
return alt_chan return alt_chan
end end
kw['grpc.primary_user_agent'] = "grpc-ruby/#{VERSION}" kw['grpc.primary_user_agent'] = "grpc-ruby/#{VERSION}"
return Core::Channel.new(host, kw) if creds.nil? unless creds.is_a?(Core::ChannelCredentials) || creds.is_a?(Symbol)
unless creds.is_a?(Core::ChannelCredentials) fail(TypeError, '!ChannelCredentials or Symbol')
fail(TypeError, '!ChannelCredentials')
end end
Core::Channel.new(host, kw, creds) Core::Channel.new(host, kw, creds)
end end
@ -68,7 +67,8 @@ module GRPC
# Minimally, a stub is created with the just the host of the gRPC service # Minimally, a stub is created with the just the host of the gRPC service
# it wishes to access, e.g., # it wishes to access, e.g.,
# #
# my_stub = ClientStub.new(example.host.com:50505) # my_stub = ClientStub.new(example.host.com:50505,
# :this_channel_is_insecure)
# #
# Any arbitrary keyword arguments are treated as channel arguments used to # Any arbitrary keyword arguments are treated as channel arguments used to
# configure the RPC connection to the host. # configure the RPC connection to the host.
@ -86,14 +86,14 @@ module GRPC
# #
# @param host [String] the host the stub connects to # @param host [String] the host the stub connects to
# @param q [Core::CompletionQueue] used to wait for events # @param q [Core::CompletionQueue] used to wait for events
# @param creds [Core::ChannelCredentials|Symbol] the channel credentials, or
# :this_channel_is_insecure
# @param channel_override [Core::Channel] a pre-created channel # @param channel_override [Core::Channel] a pre-created channel
# @param timeout [Number] the default timeout to use in requests # @param timeout [Number] the default timeout to use in requests
# @param creds [Core::ChannelCredentials] the channel credentials
# @param kw [KeywordArgs]the channel arguments # @param kw [KeywordArgs]the channel arguments
def initialize(host, q, def initialize(host, q, creds,
channel_override: nil, channel_override: nil,
timeout: nil, timeout: nil,
creds: nil,
propagate_mask: nil, propagate_mask: nil,
**kw) **kw)
fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue) fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue)
@ -464,7 +464,7 @@ module GRPC
method, method,
nil, # host use nil, nil, # host use nil,
deadline) deadline)
call.set_credentials credentials unless credentials.nil? call.set_credentials! credentials unless credentials.nil?
ActiveCall.new(call, @queue, marshal, unmarshal, deadline, started: false) ActiveCall.new(call, @queue, marshal, unmarshal, deadline, started: false)
end end
end end

@ -160,10 +160,12 @@ module GRPC
route_prefix = service_name route_prefix = service_name
Class.new(ClientStub) do Class.new(ClientStub) do
# @param host [String] the host the stub connects to # @param host [String] the host the stub connects to
# @param creds [Core::ChannelCredentials|Symbol] The channel
# credentials to use, or :this_channel_is_insecure otherwise
# @param kw [KeywordArgs] the channel arguments, plus any optional # @param kw [KeywordArgs] the channel arguments, plus any optional
# args for configuring the client's channel # args for configuring the client's channel
def initialize(host, **kw) def initialize(host, creds, **kw)
super(host, Core::CompletionQueue.new, **kw) super(host, Core::CompletionQueue.new, creds, **kw)
end end
# Used define_method to add a method for each rpc_desc. Each method # Used define_method to add a method for each rpc_desc. Each method

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,5 +29,5 @@
# GRPC contains the General RPC module. # GRPC contains the General RPC module.
module GRPC module GRPC
VERSION = '0.11.1' VERSION = '0.12.0'
end end

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -56,8 +56,6 @@ require 'test/proto/empty'
require 'test/proto/messages' require 'test/proto/messages'
require 'test/proto/test_services' require 'test/proto/test_services'
require 'signet/ssl_config'
AUTH_ENV = Google::Auth::CredentialsLoader::ENV_VAR AUTH_ENV = Google::Auth::CredentialsLoader::ENV_VAR
# RubyLogger defines a logger for gRPC based on the standard ruby logger. # RubyLogger defines a logger for gRPC based on the standard ruby logger.
@ -114,8 +112,8 @@ end
def create_stub(opts) def create_stub(opts)
address = "#{opts.host}:#{opts.port}" address = "#{opts.host}:#{opts.port}"
if opts.secure if opts.secure
creds = ssl_creds(opts.use_test_ca)
stub_opts = { stub_opts = {
:creds => ssl_creds(opts.use_test_ca),
GRPC::Core::Channel::SSL_TARGET => opts.host_override GRPC::Core::Channel::SSL_TARGET => opts.host_override
} }
@ -125,7 +123,7 @@ def create_stub(opts)
unless opts.oauth_scope.nil? unless opts.oauth_scope.nil?
auth_creds = Google::Auth.get_application_default(opts.oauth_scope) auth_creds = Google::Auth.get_application_default(opts.oauth_scope)
call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc) call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc)
stub_opts[:creds] = stub_opts[:creds].compose call_creds creds = creds.compose call_creds
end end
end end
@ -135,20 +133,20 @@ def create_stub(opts)
# use a metadata update proc that just adds the auth token. # use a metadata update proc that just adds the auth token.
call_creds = GRPC::Core::CallCredentials.new(proc { |md| md.merge(kw) }) call_creds = GRPC::Core::CallCredentials.new(proc { |md| md.merge(kw) })
stub_opts[:creds] = stub_opts[:creds].compose call_creds creds = creds.compose call_creds
end end
if opts.test_case == 'jwt_token_creds' # don't use a scope if opts.test_case == 'jwt_token_creds' # don't use a scope
auth_creds = Google::Auth.get_application_default auth_creds = Google::Auth.get_application_default
call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc) call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc)
stub_opts[:creds] = stub_opts[:creds].compose call_creds creds = creds.compose call_creds
end end
GRPC.logger.info("... connecting securely to #{address}") GRPC.logger.info("... connecting securely to #{address}")
Grpc::Testing::TestService::Stub.new(address, **stub_opts) Grpc::Testing::TestService::Stub.new(address, creds, **stub_opts)
else else
GRPC.logger.info("... connecting insecurely to #{address}") GRPC.logger.info("... connecting insecurely to #{address}")
Grpc::Testing::TestService::Stub.new(address) Grpc::Testing::TestService::Stub.new(address, :this_channel_is_insecure)
end end
end end
@ -266,16 +264,15 @@ class NamedTests
def per_rpc_creds def per_rpc_creds
auth_creds = Google::Auth.get_application_default(@args.oauth_scope) auth_creds = Google::Auth.get_application_default(@args.oauth_scope)
update_metadata = proc do |md|
kw = auth_creds.updater_proc.call({}) kw = auth_creds.updater_proc.call({})
end
# TODO(jtattermusch): downcase the metadata keys here to make sure call_creds = GRPC::Core::CallCredentials.new(update_metadata)
# they are not rejected by C core. This is a hotfix that should
# be addressed by introducing auto-downcasing logic.
kw = Hash[ kw.each_pair.map { |k, v| [k.downcase, v] }]
resp = perform_large_unary(fill_username: true, resp = perform_large_unary(fill_username: true,
fill_oauth_scope: true, fill_oauth_scope: true,
**kw) credentials: call_creds)
json_key = File.read(ENV[AUTH_ENV]) json_key = File.read(ENV[AUTH_ENV])
wanted_email = MultiJson.load(json_key)['client_email'] wanted_email = MultiJson.load(json_key)['client_email']
assert("#{__callee__}: bad username") { wanted_email == resp.username } assert("#{__callee__}: bad username") { wanted_email == resp.username }

@ -101,7 +101,7 @@ describe GRPC::Core::Call do
let(:fake_host) { 'localhost:10101' } let(:fake_host) { 'localhost:10101' }
before(:each) do before(:each) do
@ch = GRPC::Core::Channel.new(fake_host, nil) @ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
end end
describe '#status' do describe '#status' do

@ -45,7 +45,10 @@ describe GRPC::Core::Channel do
shared_examples '#new' do shared_examples '#new' do
it 'take a host name without channel args' do it 'take a host name without channel args' do
expect { GRPC::Core::Channel.new('dummy_host', nil) }.not_to raise_error blk = proc do
GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure)
end
expect(&blk).not_to raise_error
end end
it 'does not take a hash with bad keys as channel args' do it 'does not take a hash with bad keys as channel args' do
@ -106,13 +109,15 @@ describe GRPC::Core::Channel do
it_behaves_like '#new' it_behaves_like '#new'
def construct_with_args(a) def construct_with_args(a)
proc { GRPC::Core::Channel.new('dummy_host', a) } proc do
GRPC::Core::Channel.new('dummy_host', a, :this_channel_is_insecure)
end
end end
end end
describe '#create_call' do describe '#create_call' do
it 'creates a call OK' do it 'creates a call OK' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
deadline = Time.now + 5 deadline = Time.now + 5
@ -123,7 +128,7 @@ describe GRPC::Core::Channel do
end end
it 'raises an error if called on a closed channel' do it 'raises an error if called on a closed channel' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
ch.close ch.close
deadline = Time.now + 5 deadline = Time.now + 5
@ -136,13 +141,13 @@ describe GRPC::Core::Channel do
describe '#destroy' do describe '#destroy' do
it 'destroys a channel ok' do it 'destroys a channel ok' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.destroy } blk = proc { ch.destroy }
expect(&blk).to_not raise_error expect(&blk).to_not raise_error
end end
it 'can be called more than once without error' do it 'can be called more than once without error' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.destroy } blk = proc { ch.destroy }
blk.call blk.call
expect(&blk).to_not raise_error expect(&blk).to_not raise_error
@ -157,13 +162,13 @@ describe GRPC::Core::Channel do
describe '#close' do describe '#close' do
it 'closes a channel ok' do it 'closes a channel ok' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.close } blk = proc { ch.close }
expect(&blk).to_not raise_error expect(&blk).to_not raise_error
end end
it 'can be called more than once without error' do it 'can be called more than once without error' do
ch = GRPC::Core::Channel.new(fake_host, nil) ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.close } blk = proc { ch.close }
blk.call blk.call
expect(&blk).to_not raise_error expect(&blk).to_not raise_error

@ -397,7 +397,7 @@ describe 'the http client/server' do
@server = GRPC::Core::Server.new(@server_queue, nil) @server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure) server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@server.start @server.start
@ch = Channel.new("0.0.0.0:#{server_port}", nil) @ch = Channel.new("0.0.0.0:#{server_port}", nil, :this_channel_is_insecure)
end end
after(:example) do after(:example) do

@ -48,7 +48,8 @@ describe GRPC::ActiveCall do
@server = GRPC::Core::Server.new(@server_queue, nil) @server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(host, :this_port_is_insecure) server_port = @server.add_http2_port(host, :this_port_is_insecure)
@server.start @server.start
@ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil) @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
:this_channel_is_insecure)
end end
after(:each) do after(:each) do

@ -70,7 +70,7 @@ describe 'ClientStub' do
it 'can be created from a host and args' do it 'can be created from a host and args' do
opts = { a_channel_arg: 'an_arg' } opts = { a_channel_arg: 'an_arg' }
blk = proc do blk = proc do
GRPC::ClientStub.new(fake_host, @cq, **opts) GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end end
expect(&blk).not_to raise_error expect(&blk).not_to raise_error
end end
@ -78,7 +78,7 @@ describe 'ClientStub' do
it 'can be created with a default deadline' do it 'can be created with a default deadline' do
opts = { a_channel_arg: 'an_arg', deadline: 5 } opts = { a_channel_arg: 'an_arg', deadline: 5 }
blk = proc do blk = proc do
GRPC::ClientStub.new(fake_host, @cq, **opts) GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end end
expect(&blk).not_to raise_error expect(&blk).not_to raise_error
end end
@ -86,7 +86,7 @@ describe 'ClientStub' do
it 'can be created with an channel override' do it 'can be created with an channel override' do
opts = { a_channel_arg: 'an_arg', channel_override: @ch } opts = { a_channel_arg: 'an_arg', channel_override: @ch }
blk = proc do blk = proc do
GRPC::ClientStub.new(fake_host, @cq, **opts) GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end end
expect(&blk).not_to raise_error expect(&blk).not_to raise_error
end end
@ -94,15 +94,15 @@ describe 'ClientStub' do
it 'cannot be created with a bad channel override' do it 'cannot be created with a bad channel override' do
blk = proc do blk = proc do
opts = { a_channel_arg: 'an_arg', channel_override: Object.new } opts = { a_channel_arg: 'an_arg', channel_override: Object.new }
GRPC::ClientStub.new(fake_host, @cq, **opts) GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end end
expect(&blk).to raise_error expect(&blk).to raise_error
end end
it 'cannot be created with bad credentials' do it 'cannot be created with bad credentials' do
blk = proc do blk = proc do
opts = { a_channel_arg: 'an_arg', creds: Object.new } opts = { a_channel_arg: 'an_arg' }
GRPC::ClientStub.new(fake_host, @cq, **opts) GRPC::ClientStub.new(fake_host, @cq, Object.new, **opts)
end end
expect(&blk).to raise_error expect(&blk).to raise_error
end end
@ -112,10 +112,10 @@ describe 'ClientStub' do
blk = proc do blk = proc do
opts = { opts = {
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr', GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
a_channel_arg: 'an_arg', a_channel_arg: 'an_arg'
creds: GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
} }
GRPC::ClientStub.new(fake_host, @cq, **opts) creds = GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
GRPC::ClientStub.new(fake_host, @cq, creds, **opts)
end end
expect(&blk).to_not raise_error expect(&blk).to_not raise_error
end end
@ -130,7 +130,8 @@ describe 'ClientStub' do
it 'should send a request to/receive a reply from a server' do it 'should send a request to/receive a reply from a server' do
server_port = create_test_server server_port = create_test_server
th = run_request_response(@sent_msg, @resp, @pass) th = run_request_response(@sent_msg, @resp, @pass)
stub = GRPC::ClientStub.new("localhost:#{server_port}", @cq) stub = GRPC::ClientStub.new("localhost:#{server_port}", @cq,
:this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp) expect(get_response(stub)).to eq(@resp)
th.join th.join
end end
@ -140,7 +141,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @pass, th = run_request_response(@sent_msg, @resp, @pass,
k1: 'v1', k2: 'v2') k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp) expect(get_response(stub)).to eq(@resp)
th.join th.join
end end
@ -149,8 +150,10 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
alt_host = "localhost:#{server_port}" alt_host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @pass) th = run_request_response(@sent_msg, @resp, @pass)
ch = GRPC::Core::Channel.new(alt_host, nil) ch = GRPC::Core::Channel.new(alt_host, nil, :this_channel_is_insecure)
stub = GRPC::ClientStub.new('ignored-host', @cq, channel_override: ch) stub = GRPC::ClientStub.new('ignored-host', @cq,
:this_channel_is_insecure,
channel_override: ch)
expect(get_response(stub)).to eq(@resp) expect(get_response(stub)).to eq(@resp)
th.join th.join
end end
@ -159,7 +162,7 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @fail) th = run_request_response(@sent_msg, @resp, @fail)
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
blk = proc { get_response(stub) } blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus) expect(&blk).to raise_error(GRPC::BadStatus)
th.join th.join
@ -198,7 +201,7 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @pass) th = run_client_streamer(@sent_msgs, @resp, @pass)
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp) expect(get_response(stub)).to eq(@resp)
th.join th.join
end end
@ -208,7 +211,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @pass, th = run_client_streamer(@sent_msgs, @resp, @pass,
k1: 'v1', k2: 'v2') k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp) expect(get_response(stub)).to eq(@resp)
th.join th.join
end end
@ -217,7 +220,7 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @fail) th = run_client_streamer(@sent_msgs, @resp, @fail)
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
blk = proc { get_response(stub) } blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus) expect(&blk).to raise_error(GRPC::BadStatus)
th.join th.join
@ -256,7 +259,7 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @pass) th = run_server_streamer(@sent_msg, @replys, @pass)
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_responses(stub).collect { |r| r }).to eq(@replys) expect(get_responses(stub).collect { |r| r }).to eq(@replys)
th.join th.join
end end
@ -265,7 +268,7 @@ describe 'ClientStub' do
server_port = create_test_server server_port = create_test_server
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @fail) th = run_server_streamer(@sent_msg, @replys, @fail)
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
e = get_responses(stub) e = get_responses(stub)
expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus) expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
th.join th.join
@ -276,7 +279,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}" host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @fail, th = run_server_streamer(@sent_msg, @replys, @fail,
k1: 'v1', k2: 'v2') k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq) stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
e = get_responses(stub) e = get_responses(stub)
expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus) expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
th.join th.join
@ -320,7 +323,7 @@ describe 'ClientStub' do
it 'supports sending all the requests first', bidi: true do it 'supports sending all the requests first', bidi: true do
th = run_bidi_streamer_handle_inputs_first(@sent_msgs, @replys, th = run_bidi_streamer_handle_inputs_first(@sent_msgs, @replys,
@pass) @pass)
stub = GRPC::ClientStub.new(@host, @cq) stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub) e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@replys) expect(e.collect { |r| r }).to eq(@replys)
th.join th.join
@ -328,7 +331,7 @@ describe 'ClientStub' do
it 'supports client-initiated ping pong', bidi: true do it 'supports client-initiated ping pong', bidi: true do
th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, true) th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, true)
stub = GRPC::ClientStub.new(@host, @cq) stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub) e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@sent_msgs) expect(e.collect { |r| r }).to eq(@sent_msgs)
th.join th.join
@ -336,7 +339,7 @@ describe 'ClientStub' do
it 'supports a server-initiated ping pong', bidi: true do it 'supports a server-initiated ping pong', bidi: true do
th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, false) th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, false)
stub = GRPC::ClientStub.new(@host, @cq) stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub) e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@sent_msgs) expect(e.collect { |r| r }).to eq(@sent_msgs)
th.join th.join
@ -376,7 +379,7 @@ describe 'ClientStub' do
it 'should fail with DeadlineExceeded', bidi: true do it 'should fail with DeadlineExceeded', bidi: true do
@server.start @server.start
stub = GRPC::ClientStub.new(@host, @cq) stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
blk = proc do blk = proc do
e = stub.bidi_streamer(@method, @sent_msgs, noop, noop, e = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
timeout: 0.001) timeout: 0.001)

@ -141,7 +141,7 @@ describe GRPC::RpcServer do
@server = GRPC::Core::Server.new(@server_queue, nil) @server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure) server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@host = "localhost:#{server_port}" @host = "localhost:#{server_port}"
@ch = GRPC::Core::Channel.new(@host, nil) @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
end end
describe '#new' do describe '#new' do
@ -355,7 +355,8 @@ describe GRPC::RpcServer do
req = EchoMsg.new req = EchoMsg.new
blk = proc do blk = proc do
cq = GRPC::Core::CompletionQueue.new cq = GRPC::Core::CompletionQueue.new
stub = GRPC::ClientStub.new(@host, cq, **client_opts) stub = GRPC::ClientStub.new(@host, cq, :this_channel_is_insecure,
**client_opts)
stub.request_response('/unknown', req, marshal, unmarshal) stub.request_response('/unknown', req, marshal, unmarshal)
end end
expect(&blk).to raise_error GRPC::BadStatus expect(&blk).to raise_error GRPC::BadStatus
@ -369,7 +370,7 @@ describe GRPC::RpcServer do
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
n = 5 # arbitrary n = 5 # arbitrary
stub = EchoStub.new(@host, **client_opts) stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
n.times { expect(stub.an_rpc(req)).to be_a(EchoMsg) } n.times { expect(stub.an_rpc(req)).to be_a(EchoMsg) }
@srv.stop @srv.stop
t.join t.join
@ -381,7 +382,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = EchoStub.new(@host, **client_opts) stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
expect(stub.an_rpc(req, k1: 'v1', k2: 'v2')).to be_a(EchoMsg) expect(stub.an_rpc(req, k1: 'v1', k2: 'v2')).to be_a(EchoMsg)
wanted_md = [{ 'k1' => 'v1', 'k2' => 'v2' }] wanted_md = [{ 'k1' => 'v1', 'k2' => 'v2' }]
check_md(wanted_md, service.received_md) check_md(wanted_md, service.received_md)
@ -395,7 +396,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = SlowStub.new(@host, **client_opts) stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
timeout = service.delay + 1.0 # wait for long enough timeout = service.delay + 1.0 # wait for long enough
resp = stub.an_rpc(req, timeout: timeout, k1: 'v1', k2: 'v2') resp = stub.an_rpc(req, timeout: timeout, k1: 'v1', k2: 'v2')
expect(resp).to be_a(EchoMsg) expect(resp).to be_a(EchoMsg)
@ -411,7 +412,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = SlowStub.new(@host, **client_opts) stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true) op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
Thread.new do # cancel the call Thread.new do # cancel the call
sleep 0.1 sleep 0.1
@ -431,7 +432,7 @@ describe GRPC::RpcServer do
threads = [t] threads = [t]
n.times do n.times do
threads << Thread.new do threads << Thread.new do
stub = EchoStub.new(@host, **client_opts) stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
q << stub.an_rpc(req) q << stub.an_rpc(req)
end end
end end
@ -459,7 +460,7 @@ describe GRPC::RpcServer do
one_failed_as_unavailable = false one_failed_as_unavailable = false
n.times do n.times do
threads << Thread.new do threads << Thread.new do
stub = SlowStub.new(@host, **client_opts) stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
begin begin
stub.an_rpc(req) stub.an_rpc(req)
rescue GRPC::BadStatus => e rescue GRPC::BadStatus => e
@ -499,7 +500,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = EchoStub.new(@host, **client_opts) stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true) op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
expect(op.metadata).to be nil expect(op.metadata).to be nil
expect(op.execute).to be_a(EchoMsg) expect(op.execute).to be_a(EchoMsg)
@ -537,7 +538,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = FailingStub.new(@host, **client_opts) stub = FailingStub.new(@host, :this_channel_is_insecure, **client_opts)
blk = proc { stub.an_rpc(req) } blk = proc { stub.an_rpc(req) }
# confirm it raise the expected error # confirm it raise the expected error
@ -562,7 +563,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
req = EchoMsg.new req = EchoMsg.new
stub = EchoStub.new(@host, **client_opts) stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true) op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
expect(op.metadata).to be nil expect(op.metadata).to be nil
expect(op.execute).to be_a(EchoMsg) expect(op.execute).to be_a(EchoMsg)

@ -241,7 +241,7 @@ describe GenericService do
end end
describe 'the generated instances' do describe 'the generated instances' do
it 'can be instanciated with just a hostname' do it 'can be instanciated with just a hostname and credentials' do
s = Class.new do s = Class.new do
include GenericService include GenericService
rpc :AnRpc, GoodMsg, GoodMsg rpc :AnRpc, GoodMsg, GoodMsg
@ -250,7 +250,10 @@ describe GenericService do
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg) rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg)
end end
client_class = s.rpc_stub_class client_class = s.rpc_stub_class
expect { client_class.new('fakehostname') }.not_to raise_error blk = proc do
client_class.new('fakehostname', :this_channel_is_insecure)
end
expect(&blk).not_to raise_error
end end
it 'has the methods defined in the service' do it 'has the methods defined in the service' do
@ -262,7 +265,7 @@ describe GenericService do
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg) rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg)
end end
client_class = s.rpc_stub_class client_class = s.rpc_stub_class
o = client_class.new('fakehostname') o = client_class.new('fakehostname', :this_channel_is_insecure)
expect(o.methods).to include(:an_rpc) expect(o.methods).to include(:an_rpc)
expect(o.methods).to include(:a_bidi_streamer) expect(o.methods).to include(:a_bidi_streamer)
expect(o.methods).to include(:a_client_streamer) expect(o.methods).to include(:a_client_streamer)

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -47,13 +47,12 @@ describe 'Health protobuf code generation' do
end end
it 'should have the same content as created by code generation' do it 'should have the same content as created by code generation' do
root_dir = File.dirname( root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
File.dirname(File.dirname(File.dirname(__FILE__)))) pb_dir = File.join(root_dir, 'proto')
pb_dir = File.join(root_dir, 'pb')
# Get the current content # Get the current content
service_path = File.join(pb_dir, 'grpc', 'health', 'v1alpha', service_path = File.join(root_dir, 'ruby', 'pb', 'grpc',
'health_services.rb') 'health', 'v1alpha', 'health_services.rb')
want = nil want = nil
File.open(service_path) { |f| want = f.read } File.open(service_path) { |f| want = f.read }
@ -188,7 +187,7 @@ describe Grpc::Health::Checker do
@server = GRPC::Core::Server.new(@server_queue, nil) @server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure) server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@host = "localhost:#{server_port}" @host = "localhost:#{server_port}"
@ch = GRPC::Core::Channel.new(@host, nil) @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
@client_opts = { channel_override: @ch } @client_opts = { channel_override: @ch }
server_opts = { server_opts = {
server_override: @server, server_override: @server,
@ -208,7 +207,7 @@ describe Grpc::Health::Checker do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
stub = CheckerStub.new(@host, **@client_opts) stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts)
got = stub.check(HCReq.new) got = stub.check(HCReq.new)
want = HCResp.new(status: ServingStatus::NOT_SERVING) want = HCResp.new(status: ServingStatus::NOT_SERVING)
expect(got).to eq(want) expect(got).to eq(want)
@ -221,7 +220,7 @@ describe Grpc::Health::Checker do
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
blk = proc do blk = proc do
stub = CheckerStub.new(@host, **@client_opts) stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts)
stub.check(HCReq.new(host: 'unknown', service: 'unknown')) stub.check(HCReq.new(host: 'unknown', service: 'unknown'))
end end
expected_msg = /#{StatusCodes::NOT_FOUND}/ expected_msg = /#{StatusCodes::NOT_FOUND}/

@ -0,0 +1,58 @@
%YAML 1.2
--- |
# -*- ruby -*-
# encoding: utf-8
$LOAD_PATH.push File.expand_path('../src/ruby/lib', __FILE__)
require 'grpc/version'
Gem::Specification.new do |s|
s.name = 'grpc'
s.version = GRPC::VERSION
s.authors = ['gRPC Authors']
s.email = 'temiola@google.com'
s.homepage = 'https://github.com/google/grpc/tree/master/src/ruby'
s.summary = 'GRPC system in Ruby'
s.description = 'Send RPCs from Ruby using GRPC'
s.license = 'BSD-3-Clause'
s.required_ruby_version = '>= 2.0.0'
s.requirements << 'libgrpc ~> 0.11.0 needs to be installed'
s.files = %w( Rakefile Makefile )
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
s.files += Dir.glob('src/ruby/lib/**/*')
s.files += Dir.glob('src/ruby/pb/**/*')
s.files += Dir.glob('include/grpc/**/*')
s.test_files = Dir.glob('src/ruby/spec/**/*')
s.bindir = 'src/ruby/bin'
${'%'}w(math noproto).each do |b|
s.executables += ["#{b}_client.rb", "#{b}_server.rb"]
end
s.executables += %w(grpc_ruby_interop_client grpc_ruby_interop_server)
s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1'
s.add_dependency 'googleauth', '~> 0.5.1'
s.add_development_dependency 'bundler', '~> 1.9'
s.add_development_dependency 'logging', '~> 2.0'
s.add_development_dependency 'simplecov', '~> 0.9'
s.add_development_dependency 'rake', '~> 10.4'
s.add_development_dependency 'rake-compiler', '~> 0.9'
s.add_development_dependency 'rspec', '~> 3.2'
s.add_development_dependency 'rubocop', '~> 0.30.0'
s.add_development_dependency 'signet', '~>0.7.0'
s.extensions = %w(src/ruby/ext/grpc/extconf.rb)
% for lib in libs:
% if lib.name in ('gpr', 'grpc'):
% for file in lib.public_headers + lib.headers + lib.src:
s.files += %w( ${file} )
% endfor
% endif
% endfor
end

@ -0,0 +1,74 @@
%YAML 1.2
--- |
{
"name": "grpc",
"version": "0.12.0",
"author": "Google Inc.",
"description": "gRPC Library for Node",
"homepage": "http://www.grpc.io/",
"repository": {
"type": "git",
"url": "https://github.com/grpc/grpc.git"
},
"bugs": "https://github.com/grpc/grpc/issues",
"contributors": [
{
"name": "Michael Lumish",
"email": "mlumish@google.com"
}
],
"directories": {
"lib": "src/node/src"
},
"scripts": {
"lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js",
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test"
},
"dependencies": {
"bindings": "^1.2.0",
"lodash": "^3.9.3",
"nan": "^2.0.0",
"protobufjs": "^4.0.0"
},
"devDependencies": {
"async": "^1.5.0",
"google-auth-library": "^0.9.2",
"istanbul": "^0.3.21",
"jsdoc": "^3.3.2",
"jshint": "^2.5.0",
"minimist": "^1.1.0",
"mocha": "^2.3.4",
"mocha-jenkins-reporter": "^0.1.9",
"mustache": "^2.0.0",
"poisson-process": "^0.2.1"
},
"engines": {
"node": ">=0.10.13"
},
"files": [
"LICENSE",
"src/node/README.md",
"src/node/health_check",
"src/proto",
"etc",
% for module in node_modules:
% for file in module.headers + module.src + module.js:
"${file}",
% endfor
% for dep in module.transitive_deps:
% for lib in libs:
% if lib.name == dep:
% for file in lib.get('public_headers', []) + lib.headers + lib.src:
"${file}",
% endfor
% endif
% endfor
% endfor
% endfor
"binding.gyp"
],
"main": "src/node/index.js",
"license": "BSD-3-Clause"
}

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,6 +35,10 @@
#include <string.h> #include <string.h>
/* This is here for grpc_is_binary_header
* TODO(murgatroid99): Remove this
*/
#include <grpc/grpc.h>
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

@ -104,7 +104,7 @@ RE_LICENSE = dict(
def load(name): def load(name):
with open(name) as f: with open(name) as f:
return '\n'.join(line.rstrip() for line in f.read().splitlines()) return f.read()
def save(name, text): def save(name, text):
with open(name, 'w') as f: with open(name, 'w') as f:
@ -161,4 +161,3 @@ for filename in subprocess.check_output('git ls-tree -r --name-only -r HEAD',
ok = False ok = False
sys.exit(0 if ok else 1) sys.exit(0 if ok else 1)

@ -38,4 +38,3 @@ docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format
# run clang-format against the checked out codebase # run clang-format against the checked out codebase
docker run -e TEST=$TEST --rm=true -v ${HOST_GIT_ROOT:-`pwd`}:/local-code -t grpc_clang_format /clang_format_all_the_things.sh docker run -e TEST=$TEST --rm=true -v ${HOST_GIT_ROOT:-`pwd`}:/local-code -t grpc_clang_format /clang_format_all_the_things.sh

@ -1014,6 +1014,7 @@ src/core/surface/metadata_array.c \
src/core/surface/server.c \ src/core/surface/server.c \
src/core/surface/server_chttp2.c \ src/core/surface/server_chttp2.c \
src/core/surface/server_create.c \ src/core/surface/server_create.c \
src/core/surface/validate_metadata.c \
src/core/surface/version.c \ src/core/surface/version.c \
src/core/transport/byte_stream.c \ src/core/transport/byte_stream.c \
src/core/transport/chttp2/alpn.c \ src/core/transport/chttp2/alpn.c \

@ -34,7 +34,7 @@ set -ex
export GRPC_CONFIG=${CONFIG:-opt} export GRPC_CONFIG=${CONFIG:-opt}
# change to grpc's ruby directory # change to grpc's ruby directory
cd $(dirname $0)/../../src/ruby cd $(dirname $0)/../..
rm -rf ./tmp rm -rf ./tmp
rake compile:grpc rake compile:grpc

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

@ -31,6 +31,6 @@
set -ex set -ex
# change to grpc repo root # change to grpc repo root
cd $(dirname $0)/../../src/ruby cd $(dirname $0)/../..
rake rake

@ -3245,6 +3245,7 @@
"src/core/surface/server_chttp2.c", "src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c", "src/core/surface/server_create.c",
"src/core/surface/surface_trace.h", "src/core/surface/surface_trace.h",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c", "src/core/surface/version.c",
"src/core/transport/byte_stream.c", "src/core/transport/byte_stream.c",
"src/core/transport/byte_stream.h", "src/core/transport/byte_stream.h",
@ -3716,6 +3717,7 @@
"src/core/surface/server_chttp2.c", "src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c", "src/core/surface/server_create.c",
"src/core/surface/surface_trace.h", "src/core/surface/surface_trace.h",
"src/core/surface/validate_metadata.c",
"src/core/surface/version.c", "src/core/surface/version.c",
"src/core/transport/byte_stream.c", "src/core/transport/byte_stream.c",
"src/core/transport/byte_stream.h", "src/core/transport/byte_stream.h",

@ -640,6 +640,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\validate_metadata.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\transport\byte_stream.c"> <ClCompile Include="$(SolutionDir)\..\src\core\transport\byte_stream.c">

@ -352,6 +352,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c">
<Filter>src\core\surface</Filter> <Filter>src\core\surface</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\validate_metadata.c">
<Filter>src\core\surface</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c">
<Filter>src\core\surface</Filter> <Filter>src\core\surface</Filter>
</ClCompile> </ClCompile>

@ -578,6 +578,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\validate_metadata.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\transport\byte_stream.c"> <ClCompile Include="$(SolutionDir)\..\src\core\transport\byte_stream.c">

@ -292,6 +292,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\server_create.c">
<Filter>src\core\surface</Filter> <Filter>src\core\surface</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\validate_metadata.c">
<Filter>src\core\surface</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c"> <ClCompile Include="$(SolutionDir)\..\src\core\surface\version.c">
<Filter>src\core\surface</Filter> <Filter>src\core\surface</Filter>
</ClCompile> </ClCompile>

Loading…
Cancel
Save