Merge pull request #567 from tbetbetbe/grpc_ruby_rename_modules

Grpc ruby rename modules
pull/366/merge
Michael Lumish 10 years ago
commit 3c665f56be
  1. 4
      src/ruby/ext/grpc/rb_byte_buffer.c
  2. 2
      src/ruby/ext/grpc/rb_byte_buffer.h
  3. 12
      src/ruby/ext/grpc/rb_call.c
  4. 2
      src/ruby/ext/grpc/rb_call.h
  5. 4
      src/ruby/ext/grpc/rb_channel.c
  6. 2
      src/ruby/ext/grpc/rb_channel.h
  7. 4
      src/ruby/ext/grpc/rb_completion_queue.c
  8. 2
      src/ruby/ext/grpc/rb_completion_queue.h
  9. 4
      src/ruby/ext/grpc/rb_credentials.c
  10. 2
      src/ruby/ext/grpc/rb_credentials.h
  11. 8
      src/ruby/ext/grpc/rb_event.c
  12. 2
      src/ruby/ext/grpc/rb_event.h
  13. 46
      src/ruby/ext/grpc/rb_grpc.c
  14. 7
      src/ruby/ext/grpc/rb_grpc.h
  15. 4
      src/ruby/ext/grpc/rb_metadata.c
  16. 2
      src/ruby/ext/grpc/rb_metadata.h
  17. 4
      src/ruby/ext/grpc/rb_server.c
  18. 2
      src/ruby/ext/grpc/rb_server.h
  19. 4
      src/ruby/ext/grpc/rb_server_credentials.c
  20. 2
      src/ruby/ext/grpc/rb_server_credentials.h
  21. 3
      src/ruby/lib/grpc.rb
  22. 4
      src/ruby/lib/grpc/auth/compute_engine.rb
  23. 4
      src/ruby/lib/grpc/auth/service_account.rb
  24. 7
      src/ruby/lib/grpc/core/event.rb
  25. 5
      src/ruby/lib/grpc/core/time_consts.rb
  26. 6
      src/ruby/lib/grpc/errors.rb
  27. 6
      src/ruby/lib/grpc/generic/active_call.rb
  28. 6
      src/ruby/lib/grpc/generic/bidi_call.rb
  29. 6
      src/ruby/lib/grpc/generic/client_stub.rb
  30. 5
      src/ruby/lib/grpc/generic/rpc_desc.rb
  31. 6
      src/ruby/lib/grpc/generic/rpc_server.rb
  32. 6
      src/ruby/lib/grpc/generic/service.rb
  33. 6
      src/ruby/lib/grpc/logconfig.rb
  34. 6
      src/ruby/lib/grpc/version.rb
  35. 4
      src/ruby/spec/auth/compute_engine_spec.rb
  36. 4
      src/ruby/spec/auth/service_account_spec.rb

@ -202,9 +202,9 @@ static VALUE grpc_rb_byte_buffer_init(VALUE self, VALUE src) {
/* rb_cByteBuffer is the ruby class that proxies grpc_byte_buffer. */
VALUE rb_cByteBuffer = Qnil;
void Init_google_rpc_byte_buffer() {
void Init_grpc_byte_buffer() {
rb_cByteBuffer =
rb_define_class_under(rb_mGoogleRpcCore, "ByteBuffer", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "ByteBuffer", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cByteBuffer, grpc_rb_byte_buffer_alloc);

@ -42,7 +42,7 @@
extern VALUE rb_cByteBuffer;
/* Initializes the ByteBuffer class. */
void Init_google_rpc_byte_buffer();
void Init_grpc_byte_buffer();
/* grpc_rb_byte_buffer_create_with_mark creates a grpc_rb_byte_buffer with a
* ruby mark object that will be kept alive while the byte_buffer is alive. */

@ -449,9 +449,9 @@ VALUE rb_cCall = Qnil;
operations; */
VALUE rb_eCallError = Qnil;
void Init_google_rpc_error_codes() {
void Init_grpc_error_codes() {
/* Constants representing the error codes of grpc_call_error in grpc.h */
VALUE rb_RpcErrors = rb_define_module_under(rb_mGoogleRpcCore, "RpcErrors");
VALUE rb_RpcErrors = rb_define_module_under(rb_mGrpcCore, "RpcErrors");
rb_define_const(rb_RpcErrors, "OK", UINT2NUM(GRPC_CALL_OK));
rb_define_const(rb_RpcErrors, "ERROR", UINT2NUM(GRPC_CALL_ERROR));
rb_define_const(rb_RpcErrors, "NOT_ON_SERVER",
@ -500,11 +500,11 @@ void Init_google_rpc_error_codes() {
rb_obj_freeze(rb_error_code_details);
}
void Init_google_rpc_call() {
void Init_grpc_call() {
/* CallError inherits from Exception to signal that it is non-recoverable */
rb_eCallError =
rb_define_class_under(rb_mGoogleRpcCore, "CallError", rb_eException);
rb_cCall = rb_define_class_under(rb_mGoogleRpcCore, "Call", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "CallError", rb_eException);
rb_cCall = rb_define_class_under(rb_mGrpcCore, "Call", rb_cObject);
/* Prevent allocation or inialization of the Call class */
rb_define_alloc_func(rb_cCall, grpc_rb_cannot_alloc);
@ -542,7 +542,7 @@ void Init_google_rpc_call() {
hash_all_calls = rb_hash_new();
rb_define_const(rb_cCall, "INTERNAL_ALL_CALLs", hash_all_calls);
Init_google_rpc_error_codes();
Init_grpc_error_codes();
}
/* Gets the call from the ruby object */

@ -54,6 +54,6 @@ extern VALUE rb_cCall;
extern VALUE rb_eCallError;
/* Initializes the Call class. */
void Init_google_rpc_call();
void Init_grpc_call();
#endif /* GRPC_RB_CALL_H_ */

@ -227,9 +227,9 @@ static VALUE grpc_rb_channel_destroy(VALUE self) {
/* rb_cChannel is the ruby class that proxies grpc_channel. */
VALUE rb_cChannel = Qnil;
void Init_google_rpc_channel() {
void Init_grpc_channel() {
rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
rb_cChannel = rb_define_class_under(rb_mGoogleRpcCore, "Channel", rb_cObject);
rb_cChannel = rb_define_class_under(rb_mGrpcCore, "Channel", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cChannel, grpc_rb_channel_alloc);

@ -41,7 +41,7 @@
extern VALUE rb_cChannel;
/* Initializes the Channel class. */
void Init_google_rpc_channel();
void Init_grpc_channel();
/* Gets the wrapped channel from the ruby wrapper */
grpc_channel* grpc_rb_get_wrapped_channel(VALUE v);

@ -159,9 +159,9 @@ static VALUE grpc_rb_completion_queue_pluck(VALUE self, VALUE tag,
/* rb_cCompletionQueue is the ruby class that proxies grpc_completion_queue. */
VALUE rb_cCompletionQueue = Qnil;
void Init_google_rpc_completion_queue() {
void Init_grpc_completion_queue() {
rb_cCompletionQueue =
rb_define_class_under(rb_mGoogleRpcCore, "CompletionQueue", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "CompletionQueue", rb_cObject);
/* constructor: uses an alloc func without an initializer. Using a simple
alloc func works here as the grpc header does not specify any args for

@ -45,6 +45,6 @@ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v);
extern VALUE rb_cCompletionQueue;
/* Initializes the CompletionQueue class. */
void Init_google_rpc_completion_queue();
void Init_grpc_completion_queue();
#endif /* GRPC_RB_COMPLETION_QUEUE_H_ */

@ -245,9 +245,9 @@ static VALUE grpc_rb_credentials_init(int argc, VALUE *argv, VALUE self) {
/* rb_cCredentials is the ruby class that proxies grpc_credentials. */
VALUE rb_cCredentials = Qnil;
void Init_google_rpc_credentials() {
void Init_grpc_credentials() {
rb_cCredentials =
rb_define_class_under(rb_mGoogleRpcCore, "Credentials", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "Credentials", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cCredentials, grpc_rb_credentials_alloc);

@ -42,7 +42,7 @@
extern VALUE rb_cCredentials;
/* Initializes the ruby Credentials class. */
void Init_google_rpc_credentials();
void Init_grpc_credentials();
/* Gets the wrapped credentials from the ruby wrapper */
grpc_credentials* grpc_rb_get_wrapped_credentials(VALUE v);

@ -312,10 +312,10 @@ VALUE rb_cEvent = Qnil;
rpc event processing. */
VALUE rb_eEventError = Qnil;
void Init_google_rpc_event() {
void Init_grpc_event() {
rb_eEventError =
rb_define_class_under(rb_mGoogleRpcCore, "EventError", rb_eStandardError);
rb_cEvent = rb_define_class_under(rb_mGoogleRpcCore, "Event", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "EventError", rb_eStandardError);
rb_cEvent = rb_define_class_under(rb_mGrpcCore, "Event", rb_cObject);
/* Prevent allocation or inialization from ruby. */
rb_define_alloc_func(rb_cEvent, grpc_rb_cannot_alloc);
@ -332,7 +332,7 @@ void Init_google_rpc_event() {
/* Constants representing the completion types */
rb_mCompletionType =
rb_define_module_under(rb_mGoogleRpcCore, "CompletionType");
rb_define_module_under(rb_mGrpcCore, "CompletionType");
rb_define_const(rb_mCompletionType, "QUEUE_SHUTDOWN",
INT2NUM(GRPC_QUEUE_SHUTDOWN));
rb_define_const(rb_mCompletionType, "OP_COMPLETE", INT2NUM(GRPC_OP_COMPLETE));

@ -48,6 +48,6 @@ extern VALUE rb_eEventError;
VALUE grpc_rb_new_event(grpc_event *ev);
/* Initializes the Event and EventError classes. */
void Init_google_rpc_event();
void Init_grpc_event();
#endif /* GRPC_RB_EVENT_H_ */

@ -153,10 +153,10 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
return t;
}
void Init_google_status_codes() {
void Init_grpc_status_codes() {
/* Constants representing the status codes or grpc_status_code in status.h */
VALUE rb_mStatusCodes =
rb_define_module_under(rb_mGoogleRpcCore, "StatusCodes");
rb_define_module_under(rb_mGrpcCore, "StatusCodes");
rb_define_const(rb_mStatusCodes, "OK", INT2NUM(GRPC_STATUS_OK));
rb_define_const(rb_mStatusCodes, "CANCELLED", INT2NUM(GRPC_STATUS_CANCELLED));
rb_define_const(rb_mStatusCodes, "UNKNOWN", INT2NUM(GRPC_STATUS_UNKNOWN));
@ -214,11 +214,11 @@ VALUE grpc_rb_time_val_to_s(VALUE self) {
}
/* Adds a module with constants that map to gpr's static timeval structs. */
void Init_google_time_consts() {
void Init_grpc_time_consts() {
VALUE rb_mTimeConsts =
rb_define_module_under(rb_mGoogleRpcCore, "TimeConsts");
rb_define_module_under(rb_mGrpcCore, "TimeConsts");
rb_cTimeVal =
rb_define_class_under(rb_mGoogleRpcCore, "TimeSpec", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "TimeSpec", rb_cObject);
rb_define_const(rb_mTimeConsts, "ZERO",
Data_Wrap_Struct(rb_cTimeVal, GC_NOT_MARKED, GC_DONT_FREE,
(void *)&gpr_time_0));
@ -240,37 +240,35 @@ void Init_google_time_consts() {
void grpc_rb_shutdown(void *vm) { grpc_shutdown(); }
/* Initialize the Google RPC module structs */
/* Initialize the GRPC module structs */
/* rb_sNewServerRpc is the struct that holds new server rpc details. */
VALUE rb_sNewServerRpc = Qnil;
/* rb_sStatus is the struct that holds status details. */
VALUE rb_sStatus = Qnil;
/* Initialize the Google RPC module. */
VALUE rb_mGoogle = Qnil;
VALUE rb_mGoogleRPC = Qnil;
VALUE rb_mGoogleRpcCore = Qnil;
/* Initialize the GRPC module. */
VALUE rb_mGRPC = Qnil;
VALUE rb_mGrpcCore = Qnil;
void Init_grpc() {
grpc_init();
ruby_vm_at_exit(grpc_rb_shutdown);
rb_mGoogle = rb_define_module("Google");
rb_mGoogleRPC = rb_define_module_under(rb_mGoogle, "RPC");
rb_mGoogleRpcCore = rb_define_module_under(rb_mGoogleRPC, "Core");
rb_mGRPC = rb_define_module("GRPC");
rb_mGrpcCore = rb_define_module_under(rb_mGRPC, "Core");
rb_sNewServerRpc = rb_struct_define("NewServerRpc", "method", "host",
"deadline", "metadata", NULL);
rb_sStatus = rb_struct_define("Status", "code", "details", "metadata", NULL);
Init_google_rpc_byte_buffer();
Init_google_rpc_event();
Init_google_rpc_channel();
Init_google_rpc_completion_queue();
Init_google_rpc_call();
Init_google_rpc_credentials();
Init_google_rpc_metadata();
Init_google_rpc_server();
Init_google_rpc_server_credentials();
Init_google_status_codes();
Init_google_time_consts();
Init_grpc_byte_buffer();
Init_grpc_event();
Init_grpc_channel();
Init_grpc_completion_queue();
Init_grpc_call();
Init_grpc_credentials();
Init_grpc_metadata();
Init_grpc_server();
Init_grpc_server_credentials();
Init_grpc_status_codes();
Init_grpc_time_consts();
}

@ -38,11 +38,8 @@
#include <ruby.h>
#include <grpc/support/time.h>
/* rb_mGoogle is the top-level Google module. */
extern VALUE rb_mGoogle;
/* rb_mGoogleRpcCore is the module containing the ruby wrapper GRPC classes. */
extern VALUE rb_mGoogleRpcCore;
/* rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
extern VALUE rb_mGrpcCore;
/* Class used to wrap timeval structs. */
extern VALUE rb_cTimeVal;

@ -187,9 +187,9 @@ static VALUE grpc_rb_metadata_value(VALUE self) {
/* rb_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
VALUE rb_cMetadata = Qnil;
void Init_google_rpc_metadata() {
void Init_grpc_metadata() {
rb_cMetadata =
rb_define_class_under(rb_mGoogleRpcCore, "Metadata", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "Metadata", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cMetadata, grpc_rb_metadata_alloc);

@ -48,6 +48,6 @@ extern VALUE grpc_rb_metadata_create_with_mark(VALUE mark, grpc_metadata* md);
grpc_metadata* grpc_rb_get_wrapped_metadata(VALUE v);
/* Initializes the Metadata class. */
void Init_google_rpc_metadata();
void Init_grpc_metadata();
#endif /* GRPC_RB_METADATA_H_ */

@ -251,8 +251,8 @@ static VALUE grpc_rb_server_add_http2_port(int argc, VALUE *argv, VALUE self) {
return INT2NUM(recvd_port);
}
void Init_google_rpc_server() {
rb_cServer = rb_define_class_under(rb_mGoogleRpcCore, "Server", rb_cObject);
void Init_grpc_server() {
rb_cServer = rb_define_class_under(rb_mGrpcCore, "Server", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cServer, grpc_rb_server_alloc);

@ -42,7 +42,7 @@
extern VALUE rb_cServer;
/* Initializes the Server class. */
void Init_google_rpc_server();
void Init_grpc_server();
/* Gets the wrapped server from the ruby wrapper */
grpc_server* grpc_rb_get_wrapped_server(VALUE v);

@ -184,9 +184,9 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
grpc_server_credentials. */
VALUE rb_cServerCredentials = Qnil;
void Init_google_rpc_server_credentials() {
void Init_grpc_server_credentials() {
rb_cServerCredentials =
rb_define_class_under(rb_mGoogleRpcCore, "ServerCredentials", rb_cObject);
rb_define_class_under(rb_mGrpcCore, "ServerCredentials", rb_cObject);
/* Allocates an object managed by the ruby runtime */
rb_define_alloc_func(rb_cServerCredentials, grpc_rb_server_credentials_alloc);

@ -42,7 +42,7 @@
extern VALUE rb_cServerCredentials;
/* Initializes the ruby ServerCredentials class. */
void Init_google_rpc_server_credentials();
void Init_grpc_server_credentials();
/* Gets the wrapped server_credentials from the ruby wrapper */
grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v);

@ -39,6 +39,3 @@ require 'grpc/generic/active_call'
require 'grpc/generic/client_stub'
require 'grpc/generic/service'
require 'grpc/generic/rpc_server'
# alias GRPC
GRPC = Google::RPC

@ -30,8 +30,7 @@
require 'faraday'
require 'grpc/auth/signet'
module Google
module RPC
module GRPC
# Module Auth provides classes that provide Google-specific authentication
# used to access Google gRPC services.
module Auth
@ -66,4 +65,3 @@ module Google
end
end
end
end

@ -39,8 +39,7 @@ def read_json_key(json_key_io)
[json_key['private_key'], json_key['client_email']]
end
module Google
module RPC
module GRPC
# Module Auth provides classes that provide Google-specific authentication
# used to access Google gRPC services.
module Auth
@ -65,4 +64,3 @@ module Google
end
end
end
end

@ -27,8 +27,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Google
module RPC
require 'grpc'
# GRPC contains the General RPC module.
module GRPC
module Core
# Event is a class defined in the c extension
#
@ -40,4 +42,3 @@ module Google
end
end
end
end

@ -29,8 +29,8 @@
require 'grpc'
module Google
module RPC
# GRPC contains the General RPC module.
module GRPC
module Core
# TimeConsts is a module from the C extension.
#
@ -69,4 +69,3 @@ module Google
end
end
end
end

@ -29,9 +29,8 @@
require 'grpc'
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# OutOfTime is an exception class that indicates that an RPC exceeded its
# deadline.
OutOfTime = Class.new(StandardError)
@ -60,4 +59,3 @@ module Google
end
end
end
end

@ -36,9 +36,8 @@ def assert_event_type(ev, want)
fail "Unexpected rpc event: got #{got}, want #{want}" unless got == want
end
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# The ActiveCall class provides simple methods for sending marshallable
# data to a call
class ActiveCall
@ -535,4 +534,3 @@ module Google
end
end
end
end

@ -36,9 +36,8 @@ def assert_event_type(ev, want)
fail("Unexpected rpc event: got #{got}, want #{want}") unless got == want
end
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# The BiDiCall class orchestrates exection of a BiDi stream on a client or
# server.
class BidiCall
@ -220,4 +219,3 @@ module Google
end
end
end
end

@ -30,9 +30,8 @@
require 'grpc/generic/active_call'
require 'xray/thread_dump_signal_handler'
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# ClientStub represents an endpoint used to send requests to GRPC servers.
class ClientStub
include Core::StatusCodes
@ -407,4 +406,3 @@ module Google
end
end
end
end

@ -29,8 +29,8 @@
require 'grpc/grpc'
module Google
module RPC
# GRPC contains the General RPC module.
module GRPC
# RpcDesc is a Descriptor of an RPC method.
class RpcDesc < Struct.new(:name, :input, :output, :marshal_method,
:unmarshal_method)
@ -148,4 +148,3 @@ module Google
end
end
end
end

@ -33,9 +33,8 @@ require 'grpc/generic/service'
require 'thread'
require 'xray/thread_dump_signal_handler'
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# RpcServer hosts a number of services and makes them available on the
# network.
class RpcServer
@ -403,4 +402,3 @@ module Google
end
end
end
end

@ -48,9 +48,8 @@ class String
end
end
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
# Provides behaviour used to implement schema-derived service classes.
#
# Is intended to be used to support both client and server
@ -234,4 +233,3 @@ module Google
end
end
end
end

@ -35,6 +35,6 @@ Logging.logger.root.appenders = Logging.appenders.stdout
Logging.logger.root.level = :info
# TODO: provide command-line configuration for logging
Logging.logger['Google::RPC'].level = :debug
Logging.logger['Google::RPC::ActiveCall'].level = :info
Logging.logger['Google::RPC::BidiCall'].level = :info
Logging.logger['GRPC'].level = :debug
Logging.logger['GRPC::ActiveCall'].level = :info
Logging.logger['GRPC::BidiCall'].level = :info

@ -27,9 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Google
# Google::RPC contains the General RPC module.
module RPC
# GRPC contains the General RPC module.
module GRPC
VERSION = '0.0.1'
end
end

@ -36,9 +36,9 @@ require 'faraday'
require 'grpc/auth/compute_engine'
require 'spec_helper'
describe Google::RPC::Auth::GCECredentials do
describe GRPC::Auth::GCECredentials do
MD_URI = '/computeMetadata/v1/instance/service-accounts/default/token'
GCECredentials = Google::RPC::Auth::GCECredentials
GCECredentials = GRPC::Auth::GCECredentials
before(:example) do
@client = GCECredentials.new

@ -38,7 +38,7 @@ require 'multi_json'
require 'openssl'
require 'spec_helper'
describe Google::RPC::Auth::ServiceAccountCredentials do
describe GRPC::Auth::ServiceAccountCredentials do
before(:example) do
@key = OpenSSL::PKey::RSA.new(2048)
cred_json = {
@ -49,7 +49,7 @@ describe Google::RPC::Auth::ServiceAccountCredentials do
type: 'service_account'
}
cred_json_text = MultiJson.dump(cred_json)
@client = Google::RPC::Auth::ServiceAccountCredentials.new(
@client = GRPC::Auth::ServiceAccountCredentials.new(
'https://www.googleapis.com/auth/userinfo.profile',
StringIO.new(cred_json_text))
end

Loading…
Cancel
Save