From 5b4d3625ebbf638080d07b7d267c5d90904d4f14 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Wed, 3 Aug 2016 15:33:37 -0700 Subject: Update ruby examples to use new _pb protobuf format --- examples/ruby/greeter_client.rb | 2 +- examples/ruby/greeter_server.rb | 2 +- examples/ruby/grpc-demo.gemspec | 4 +- examples/ruby/lib/helloworld.rb | 18 ------ examples/ruby/lib/helloworld_pb.rb | 18 ++++++ examples/ruby/lib/helloworld_services.rb | 54 ------------------ examples/ruby/lib/helloworld_services_pb.rb | 54 ++++++++++++++++++ examples/ruby/lib/route_guide.rb | 37 ------------ examples/ruby/lib/route_guide_pb.rb | 37 ++++++++++++ examples/ruby/lib/route_guide_services.rb | 76 ------------------------- examples/ruby/lib/route_guide_services_pb.rb | 76 +++++++++++++++++++++++++ examples/ruby/route_guide/route_guide_client.rb | 2 +- examples/ruby/route_guide/route_guide_server.rb | 2 +- 13 files changed, 191 insertions(+), 191 deletions(-) delete mode 100644 examples/ruby/lib/helloworld.rb create mode 100644 examples/ruby/lib/helloworld_pb.rb delete mode 100644 examples/ruby/lib/helloworld_services.rb create mode 100644 examples/ruby/lib/helloworld_services_pb.rb delete mode 100644 examples/ruby/lib/route_guide.rb create mode 100644 examples/ruby/lib/route_guide_pb.rb delete mode 100644 examples/ruby/lib/route_guide_services.rb create mode 100644 examples/ruby/lib/route_guide_services_pb.rb (limited to 'examples/ruby') diff --git a/examples/ruby/greeter_client.rb b/examples/ruby/greeter_client.rb index cb4aa195e7..1cdf79ebf4 100755 --- a/examples/ruby/greeter_client.rb +++ b/examples/ruby/greeter_client.rb @@ -38,7 +38,7 @@ lib_dir = File.join(this_dir, 'lib') $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' -require 'helloworld_services' +require 'helloworld_services_pb' def main stub = Helloworld::Greeter::Stub.new('localhost:50051', :this_channel_is_insecure) diff --git a/examples/ruby/greeter_server.rb b/examples/ruby/greeter_server.rb index 622513d380..6d82043c52 100755 --- a/examples/ruby/greeter_server.rb +++ b/examples/ruby/greeter_server.rb @@ -38,7 +38,7 @@ lib_dir = File.join(this_dir, 'lib') $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' -require 'helloworld_services' +require 'helloworld_services_pb' # GreeterServer is simple server that implements the Helloworld Greeter server. class GreeterServer < Helloworld::Greeter::Service diff --git a/examples/ruby/grpc-demo.gemspec b/examples/ruby/grpc-demo.gemspec index b1dfdae6ab..e1b77a56ac 100644 --- a/examples/ruby/grpc-demo.gemspec +++ b/examples/ruby/grpc-demo.gemspec @@ -3,7 +3,7 @@ Gem::Specification.new do |s| s.name = 'grpc-demo' - s.version = '0.11.0' + s.version = '1.0.0' s.authors = ['gRPC Authors'] s.email = 'temiola@google.com' s.homepage = 'https://github.com/grpc/grpc' @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.platform = Gem::Platform::RUBY - s.add_dependency 'grpc', '~> 0.11' + s.add_dependency 'grpc', '~> 1.0.0' s.add_development_dependency 'bundler', '~> 1.7' end diff --git a/examples/ruby/lib/helloworld.rb b/examples/ruby/lib/helloworld.rb deleted file mode 100644 index 82bdd78e2a..0000000000 --- a/examples/ruby/lib/helloworld.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: helloworld.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "helloworld.HelloRequest" do - optional :name, :string, 1 - end - add_message "helloworld.HelloReply" do - optional :message, :string, 1 - end -end - -module Helloworld - HelloRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("helloworld.HelloRequest").msgclass - HelloReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("helloworld.HelloReply").msgclass -end diff --git a/examples/ruby/lib/helloworld_pb.rb b/examples/ruby/lib/helloworld_pb.rb new file mode 100644 index 0000000000..82bdd78e2a --- /dev/null +++ b/examples/ruby/lib/helloworld_pb.rb @@ -0,0 +1,18 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: helloworld.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "helloworld.HelloRequest" do + optional :name, :string, 1 + end + add_message "helloworld.HelloReply" do + optional :message, :string, 1 + end +end + +module Helloworld + HelloRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("helloworld.HelloRequest").msgclass + HelloReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("helloworld.HelloReply").msgclass +end diff --git a/examples/ruby/lib/helloworld_services.rb b/examples/ruby/lib/helloworld_services.rb deleted file mode 100644 index fbec667794..0000000000 --- a/examples/ruby/lib/helloworld_services.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: helloworld.proto for package 'helloworld' -# Original file comments: -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -require 'grpc' -require 'helloworld' - -module Helloworld - module Greeter - # The greeting service definition. - class Service - - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'helloworld.Greeter' - - # Sends a greeting - rpc :SayHello, HelloRequest, HelloReply - end - - Stub = Service.rpc_stub_class - end -end diff --git a/examples/ruby/lib/helloworld_services_pb.rb b/examples/ruby/lib/helloworld_services_pb.rb new file mode 100644 index 0000000000..4fee0aa2a9 --- /dev/null +++ b/examples/ruby/lib/helloworld_services_pb.rb @@ -0,0 +1,54 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: helloworld.proto for package 'helloworld' +# Original file comments: +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +require 'grpc' +require 'helloworld_pb' + +module Helloworld + module Greeter + # The greeting service definition. + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'helloworld.Greeter' + + # Sends a greeting + rpc :SayHello, HelloRequest, HelloReply + end + + Stub = Service.rpc_stub_class + end +end diff --git a/examples/ruby/lib/route_guide.rb b/examples/ruby/lib/route_guide.rb deleted file mode 100644 index 424395c4f5..0000000000 --- a/examples/ruby/lib/route_guide.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: route_guide.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "routeguide.Point" do - optional :latitude, :int32, 1 - optional :longitude, :int32, 2 - end - add_message "routeguide.Rectangle" do - optional :lo, :message, 1, "routeguide.Point" - optional :hi, :message, 2, "routeguide.Point" - end - add_message "routeguide.Feature" do - optional :name, :string, 1 - optional :location, :message, 2, "routeguide.Point" - end - add_message "routeguide.RouteNote" do - optional :location, :message, 1, "routeguide.Point" - optional :message, :string, 2 - end - add_message "routeguide.RouteSummary" do - optional :point_count, :int32, 1 - optional :feature_count, :int32, 2 - optional :distance, :int32, 3 - optional :elapsed_time, :int32, 4 - end -end - -module Routeguide - Point = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Point").msgclass - Rectangle = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Rectangle").msgclass - Feature = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Feature").msgclass - RouteNote = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteNote").msgclass - RouteSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteSummary").msgclass -end diff --git a/examples/ruby/lib/route_guide_pb.rb b/examples/ruby/lib/route_guide_pb.rb new file mode 100644 index 0000000000..424395c4f5 --- /dev/null +++ b/examples/ruby/lib/route_guide_pb.rb @@ -0,0 +1,37 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: route_guide.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "routeguide.Point" do + optional :latitude, :int32, 1 + optional :longitude, :int32, 2 + end + add_message "routeguide.Rectangle" do + optional :lo, :message, 1, "routeguide.Point" + optional :hi, :message, 2, "routeguide.Point" + end + add_message "routeguide.Feature" do + optional :name, :string, 1 + optional :location, :message, 2, "routeguide.Point" + end + add_message "routeguide.RouteNote" do + optional :location, :message, 1, "routeguide.Point" + optional :message, :string, 2 + end + add_message "routeguide.RouteSummary" do + optional :point_count, :int32, 1 + optional :feature_count, :int32, 2 + optional :distance, :int32, 3 + optional :elapsed_time, :int32, 4 + end +end + +module Routeguide + Point = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Point").msgclass + Rectangle = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Rectangle").msgclass + Feature = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.Feature").msgclass + RouteNote = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteNote").msgclass + RouteSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("routeguide.RouteSummary").msgclass +end diff --git a/examples/ruby/lib/route_guide_services.rb b/examples/ruby/lib/route_guide_services.rb deleted file mode 100644 index d8f123dd95..0000000000 --- a/examples/ruby/lib/route_guide_services.rb +++ /dev/null @@ -1,76 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: route_guide.proto for package 'routeguide' -# Original file comments: -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -require 'grpc' -require 'route_guide' - -module Routeguide - module RouteGuide - # Interface exported by the server. - class Service - - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'routeguide.RouteGuide' - - # A simple RPC. - # - # Obtains the feature at a given position. - # - # A feature with an empty name is returned if there's no feature at the given - # position. - rpc :GetFeature, Point, Feature - # A server-to-client streaming RPC. - # - # Obtains the Features available within the given Rectangle. Results are - # streamed rather than returned at once (e.g. in a response message with a - # repeated field), as the rectangle may cover a large area and contain a - # huge number of features. - rpc :ListFeatures, Rectangle, stream(Feature) - # A client-to-server streaming RPC. - # - # Accepts a stream of Points on a route being traversed, returning a - # RouteSummary when traversal is completed. - rpc :RecordRoute, stream(Point), RouteSummary - # A Bidirectional streaming RPC. - # - # Accepts a stream of RouteNotes sent while a route is being traversed, - # while receiving other RouteNotes (e.g. from other users). - rpc :RouteChat, stream(RouteNote), stream(RouteNote) - end - - Stub = Service.rpc_stub_class - end -end diff --git a/examples/ruby/lib/route_guide_services_pb.rb b/examples/ruby/lib/route_guide_services_pb.rb new file mode 100644 index 0000000000..d43fcc64e9 --- /dev/null +++ b/examples/ruby/lib/route_guide_services_pb.rb @@ -0,0 +1,76 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: route_guide.proto for package 'routeguide' +# Original file comments: +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +require 'grpc' +require 'route_guide_pb' + +module Routeguide + module RouteGuide + # Interface exported by the server. + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'routeguide.RouteGuide' + + # A simple RPC. + # + # Obtains the feature at a given position. + # + # A feature with an empty name is returned if there's no feature at the given + # position. + rpc :GetFeature, Point, Feature + # A server-to-client streaming RPC. + # + # Obtains the Features available within the given Rectangle. Results are + # streamed rather than returned at once (e.g. in a response message with a + # repeated field), as the rectangle may cover a large area and contain a + # huge number of features. + rpc :ListFeatures, Rectangle, stream(Feature) + # A client-to-server streaming RPC. + # + # Accepts a stream of Points on a route being traversed, returning a + # RouteSummary when traversal is completed. + rpc :RecordRoute, stream(Point), RouteSummary + # A Bidirectional streaming RPC. + # + # Accepts a stream of RouteNotes sent while a route is being traversed, + # while receiving other RouteNotes (e.g. from other users). + rpc :RouteChat, stream(RouteNote), stream(RouteNote) + end + + Stub = Service.rpc_stub_class + end +end diff --git a/examples/ruby/route_guide/route_guide_client.rb b/examples/ruby/route_guide/route_guide_client.rb index e7f802c21e..330725ece0 100755 --- a/examples/ruby/route_guide/route_guide_client.rb +++ b/examples/ruby/route_guide/route_guide_client.rb @@ -39,7 +39,7 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' require 'multi_json' -require 'route_guide_services' +require 'route_guide_services_pb' include Routeguide diff --git a/examples/ruby/route_guide/route_guide_server.rb b/examples/ruby/route_guide/route_guide_server.rb index bebe49b3be..a5a73a8bac 100755 --- a/examples/ruby/route_guide/route_guide_server.rb +++ b/examples/ruby/route_guide/route_guide_server.rb @@ -40,7 +40,7 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' require 'multi_json' -require 'route_guide_services' +require 'route_guide_services_pb' include Routeguide COORD_FACTOR = 1e7 -- cgit v1.2.3