aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/lib
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-05-06 14:48:21 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-05-06 14:48:21 -0700
commitcf239e73093e0c9afe457b2b4b0fe45eae514b6f (patch)
tree79317053d5fa298f4751632b2e49d8c6c925a625 /src/ruby/lib
parent8c33c7442c79682d2e545820f5653cabf25fd07e (diff)
Add a default handler to Ruby services that returns UNIMPLEMENTED
Diffstat (limited to 'src/ruby/lib')
-rw-r--r--src/ruby/lib/grpc/generic/rpc_server.rb6
-rw-r--r--src/ruby/lib/grpc/generic/service.rb16
2 files changed, 5 insertions, 17 deletions
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb
index a0f4071adc..60a8957251 100644
--- a/src/ruby/lib/grpc/generic/rpc_server.rb
+++ b/src/ruby/lib/grpc/generic/rpc_server.rb
@@ -503,10 +503,8 @@ module GRPC
unless cls.include?(GenericService)
fail "#{cls} must 'include GenericService'"
end
- if cls.rpc_descs.size.zero?
- fail "#{cls} should specify some rpc descriptions"
- end
- cls.assert_rpc_descs_have_methods
+ fail "#{cls} should specify some rpc descriptions" if
+ cls.rpc_descs.size.zero?
end
# This should be called while holding @run_mutex
diff --git a/src/ruby/lib/grpc/generic/service.rb b/src/ruby/lib/grpc/generic/service.rb
index 8e940b5b13..0a166e823e 100644
--- a/src/ruby/lib/grpc/generic/service.rb
+++ b/src/ruby/lib/grpc/generic/service.rb
@@ -110,6 +110,9 @@ module GRPC
rpc_descs[name] = RpcDesc.new(name, input, output,
marshal_class_method,
unmarshal_class_method)
+ define_method(name) do
+ fail GRPC::BadStatus, GRPC::Core::StatusCodes::UNIMPLEMENTED
+ end
end
def inherited(subclass)
@@ -199,19 +202,6 @@ module GRPC
end
end
end
-
- # Asserts that the appropriate methods are defined for each added rpc
- # spec. Is intended to aid verifying that server classes are correctly
- # implemented.
- def assert_rpc_descs_have_methods
- rpc_descs.each_pair do |m, spec|
- mth_name = GenericService.underscore(m.to_s).to_sym
- unless instance_methods.include?(mth_name)
- fail "#{self} does not provide instance method '#{mth_name}'"
- end
- spec.assert_arity_matches(instance_method(mth_name))
- end
- end
end
def self.included(o)