route_guide 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.vscode/configurationCache.log +1 -0
- data/.vscode/dryrun.log +6 -0
- data/.vscode/settings.json +3 -0
- data/.vscode/targets.log +209 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +21 -0
- data/Makefile +2 -0
- data/README.md +120 -0
- data/Rakefile +12 -0
- data/examples/client.rb +17 -0
- data/examples/directions_service.rb +13 -0
- data/examples/server.rb +24 -0
- data/lib/route_guide/route_guide_pb.rb +24 -0
- data/lib/route_guide/route_guide_services_pb.rb +22 -0
- data/lib/route_guide/version.rb +5 -0
- data/lib/route_guide.rb +8 -0
- data/proto/route_guide.proto +19 -0
- data/route_guide.gemspec +39 -0
- data/sig/route_guide.rbs +4 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 915d1d24cfa64d36e922c6fb05e3880e59d130966661a0cc62279be198731c05
|
4
|
+
data.tar.gz: 3ce5fcbd844cc890781778cc15dc922c5d53fd4f9885f0a5394f1ef923e7993f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f2b047ab7a5e51dbbf72a5e6cf30c935420291f0b1b88ded01000e0f2bf8607970711f86114bbdb3e21689cc4c66082e8ce785aebf5436d23800fb7b2c0268c
|
7
|
+
data.tar.gz: 12913483a21df373ae920220bee22cbb620597ab5981bcbade3f8a7ccc6dc71a697f66dca0c223d736c67adcfd40ed099d0b549b317bd2be8be2896801308bc9
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
|
data/.vscode/dryrun.log
ADDED
data/.vscode/targets.log
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
|
2
|
+
# GNU Make 3.81
|
3
|
+
# Copyright (C) 2006 Free Software Foundation, Inc.
|
4
|
+
# This is free software; see the source for copying conditions.
|
5
|
+
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
6
|
+
# PARTICULAR PURPOSE.
|
7
|
+
|
8
|
+
# This program built for i386-apple-darwin11.3.0
|
9
|
+
|
10
|
+
|
11
|
+
# Make data base, printed on Sat Jun 11 15:54:42 2022
|
12
|
+
|
13
|
+
# Variables
|
14
|
+
|
15
|
+
# automatic
|
16
|
+
<D = $(patsubst %/,%,$(dir $<))
|
17
|
+
# automatic
|
18
|
+
?F = $(notdir $?)
|
19
|
+
# environment
|
20
|
+
VSCODE_LOG_NATIVE = false
|
21
|
+
# automatic
|
22
|
+
?D = $(patsubst %/,%,$(dir $?))
|
23
|
+
# automatic
|
24
|
+
@D = $(patsubst %/,%,$(dir $@))
|
25
|
+
# automatic
|
26
|
+
@F = $(notdir $@)
|
27
|
+
# makefile
|
28
|
+
CURDIR := /Users/sylvancembaka/code/sylvance/grpc/route_guide
|
29
|
+
# makefile
|
30
|
+
SHELL = /bin/sh
|
31
|
+
# environment
|
32
|
+
VSCODE_NLS_CONFIG = {"locale":"en-gb","availableLanguages":{},"_languagePackSupport":true}
|
33
|
+
# environment
|
34
|
+
_ = /usr/bin/make
|
35
|
+
# makefile (from `Makefile', line 1)
|
36
|
+
MAKEFILE_LIST := Makefile
|
37
|
+
# environment
|
38
|
+
VSCODE_VERBOSE_LOGGING = true
|
39
|
+
# environment
|
40
|
+
__CFBundleIdentifier = com.microsoft.VSCode
|
41
|
+
# environment
|
42
|
+
VSCODE_IPC_HOOK_EXTHOST = /var/folders/4p/q6h4tmns22x5vtv0hsw6l8v00000gp/T/vscode-ipc-d7aeb1c1-9eab-44a3-89d1-756aea647156.sock
|
43
|
+
# environment
|
44
|
+
VSCODE_CWD = /
|
45
|
+
# environment
|
46
|
+
PATH = /usr/bin:/bin:/usr/sbin:/sbin
|
47
|
+
# environment
|
48
|
+
LaunchInstanceID = E6C66309-E4E7-40F5-B6A2-4D1A0D0F26CE
|
49
|
+
# environment
|
50
|
+
VSCODE_LOG_STACK = false
|
51
|
+
# environment
|
52
|
+
ELECTRON_RUN_AS_NODE = 1
|
53
|
+
# default
|
54
|
+
.FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink
|
55
|
+
# environment
|
56
|
+
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.yxfNK9mIf6/Listeners
|
57
|
+
# automatic
|
58
|
+
%F = $(notdir $%)
|
59
|
+
# environment
|
60
|
+
VSCODE_PIPE_LOGGING = true
|
61
|
+
# environment
|
62
|
+
PWD = /Users/sylvancembaka/code/sylvance/grpc/route_guide
|
63
|
+
# environment
|
64
|
+
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
|
65
|
+
# environment
|
66
|
+
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
|
67
|
+
# environment
|
68
|
+
HOME = /Users/sylvancembaka
|
69
|
+
# default
|
70
|
+
MAKEFILEPATH = $(shell /usr/bin/xcode-select -print-path 2>/dev/null || echo /Developer)/Makefiles
|
71
|
+
# environment
|
72
|
+
VSCODE_CODE_CACHE_PATH = /Users/sylvancembaka/Library/Application Support/Code/CachedData/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
|
73
|
+
# environment
|
74
|
+
LOGNAME = sylvancembaka
|
75
|
+
# environment
|
76
|
+
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 1
|
77
|
+
# environment
|
78
|
+
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
|
79
|
+
# automatic
|
80
|
+
^D = $(patsubst %/,%,$(dir $^))
|
81
|
+
# environment
|
82
|
+
XPC_FLAGS = 0x0
|
83
|
+
# default
|
84
|
+
MAKE = $(MAKE_COMMAND)
|
85
|
+
# default
|
86
|
+
MAKECMDGOALS := all
|
87
|
+
# environment
|
88
|
+
SHLVL = 1
|
89
|
+
# default
|
90
|
+
MAKE_VERSION := 3.81
|
91
|
+
# environment
|
92
|
+
USER = sylvancembaka
|
93
|
+
# makefile
|
94
|
+
.DEFAULT_GOAL :=
|
95
|
+
# automatic
|
96
|
+
%D = $(patsubst %/,%,$(dir $%))
|
97
|
+
# default
|
98
|
+
MAKE_COMMAND := /Library/Developer/CommandLineTools/usr/bin/make
|
99
|
+
# default
|
100
|
+
.VARIABLES :=
|
101
|
+
# environment
|
102
|
+
TMPDIR = /var/folders/4p/q6h4tmns22x5vtv0hsw6l8v00000gp/T/
|
103
|
+
# automatic
|
104
|
+
*F = $(notdir $*)
|
105
|
+
# environment
|
106
|
+
VSCODE_IPC_HOOK = /Users/sylvancembaka/Library/Application Support/Code/1.67.2-main.sock
|
107
|
+
# makefile
|
108
|
+
MAKEFLAGS = Rrqp
|
109
|
+
# environment
|
110
|
+
MFLAGS = -Rrqp
|
111
|
+
# automatic
|
112
|
+
*D = $(patsubst %/,%,$(dir $*))
|
113
|
+
# environment
|
114
|
+
XPC_SERVICE_NAME = application.com.microsoft.VSCode.43616207.43616213
|
115
|
+
# automatic
|
116
|
+
+D = $(patsubst %/,%,$(dir $+))
|
117
|
+
# automatic
|
118
|
+
+F = $(notdir $+)
|
119
|
+
# environment
|
120
|
+
__CF_USER_TEXT_ENCODING = 0x1F6:0x0:0x0
|
121
|
+
# environment
|
122
|
+
COMMAND_MODE = unix2003
|
123
|
+
# default
|
124
|
+
MAKEFILES :=
|
125
|
+
# automatic
|
126
|
+
<F = $(notdir $<)
|
127
|
+
# environment
|
128
|
+
LC_ALL = C
|
129
|
+
# environment
|
130
|
+
SECURITYSESSIONID = 186b7
|
131
|
+
# automatic
|
132
|
+
^F = $(notdir $^)
|
133
|
+
# default
|
134
|
+
SUFFIXES :=
|
135
|
+
# default
|
136
|
+
.INCLUDE_DIRS = /usr/local/include
|
137
|
+
# environment
|
138
|
+
MAKELEVEL := 0
|
139
|
+
# environment
|
140
|
+
LANG = C
|
141
|
+
# environment
|
142
|
+
VSCODE_PID = 692
|
143
|
+
# variable set hash-table stats:
|
144
|
+
# Load=64/1024=6%, Rehash=0, Collisions=1/87=1%
|
145
|
+
|
146
|
+
# Pattern-specific Variable Values
|
147
|
+
|
148
|
+
# No pattern-specific variable values.
|
149
|
+
|
150
|
+
# Directories
|
151
|
+
|
152
|
+
# . (device 16777234, inode 48140951): 21 files, no impossibilities.
|
153
|
+
|
154
|
+
# 21 files, no impossibilities in 1 directories.
|
155
|
+
|
156
|
+
# Implicit Rules
|
157
|
+
|
158
|
+
# No implicit rules.
|
159
|
+
|
160
|
+
# Files
|
161
|
+
|
162
|
+
# Not a target:
|
163
|
+
all:
|
164
|
+
# Command-line target.
|
165
|
+
# Implicit rule search has been done.
|
166
|
+
# File does not exist.
|
167
|
+
# File has not been updated.
|
168
|
+
# variable set hash-table stats:
|
169
|
+
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
170
|
+
|
171
|
+
# Not a target:
|
172
|
+
.SUFFIXES:
|
173
|
+
# Implicit rule search has not been done.
|
174
|
+
# Modification time never checked.
|
175
|
+
# File has not been updated.
|
176
|
+
|
177
|
+
# Not a target:
|
178
|
+
Makefile:
|
179
|
+
# Implicit rule search has been done.
|
180
|
+
# Last modified 2022-06-11 15:54:33
|
181
|
+
# File has been updated.
|
182
|
+
# Successfully updated.
|
183
|
+
# variable set hash-table stats:
|
184
|
+
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
185
|
+
|
186
|
+
# Not a target:
|
187
|
+
.DEFAULT:
|
188
|
+
# Implicit rule search has not been done.
|
189
|
+
# Modification time never checked.
|
190
|
+
# File has not been updated.
|
191
|
+
|
192
|
+
# files hash-table stats:
|
193
|
+
# Load=4/1024=0%, Rehash=0, Collisions=0/16=0%
|
194
|
+
# VPATH Search Paths
|
195
|
+
|
196
|
+
# No `vpath' search paths.
|
197
|
+
|
198
|
+
# No general (`VPATH' variable) search path.
|
199
|
+
|
200
|
+
# # of strings in strcache: 1
|
201
|
+
# # of strcache buffers: 1
|
202
|
+
# strcache size: total = 4096 / max = 4096 / min = 4096 / avg = 4096
|
203
|
+
# strcache free: total = 4087 / max = 4087 / min = 4087 / avg = 4087
|
204
|
+
|
205
|
+
# Finished Make data base on Sat Jun 11 15:54:42 2022
|
206
|
+
|
207
|
+
|
208
|
+
make: *** No rule to make target `all'. Stop.
|
209
|
+
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
route_guide (0.1.0)
|
5
|
+
grpc
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
google-protobuf (3.21.1)
|
13
|
+
googleapis-common-protos-types (1.3.1)
|
14
|
+
google-protobuf (~> 3.14)
|
15
|
+
grpc (1.46.3)
|
16
|
+
google-protobuf (~> 3.19)
|
17
|
+
googleapis-common-protos-types (~> 1.0)
|
18
|
+
parallel (1.22.1)
|
19
|
+
parser (3.1.2.0)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
rainbow (3.1.1)
|
22
|
+
rake (13.0.6)
|
23
|
+
regexp_parser (2.5.0)
|
24
|
+
rexml (3.2.5)
|
25
|
+
rspec (3.11.0)
|
26
|
+
rspec-core (~> 3.11.0)
|
27
|
+
rspec-expectations (~> 3.11.0)
|
28
|
+
rspec-mocks (~> 3.11.0)
|
29
|
+
rspec-core (3.11.0)
|
30
|
+
rspec-support (~> 3.11.0)
|
31
|
+
rspec-expectations (3.11.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.11.0)
|
34
|
+
rspec-mocks (3.11.1)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.11.0)
|
37
|
+
rspec-support (3.11.0)
|
38
|
+
rubocop (1.30.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 3.1.0.0)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.8, < 3.0)
|
43
|
+
rexml (>= 3.2.5, < 4.0)
|
44
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
47
|
+
rubocop-ast (1.18.0)
|
48
|
+
parser (>= 3.1.1.0)
|
49
|
+
ruby-progressbar (1.11.0)
|
50
|
+
unicode-display_width (2.1.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
arm64-darwin-20
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
rake (~> 13.0)
|
57
|
+
route_guide!
|
58
|
+
rspec (~> 3.0)
|
59
|
+
rubocop (~> 1.21)
|
60
|
+
|
61
|
+
BUNDLED WITH
|
62
|
+
2.3.15
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 sylvance_theone
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# RouteGuide
|
2
|
+
|
3
|
+
Route Guide is a gem that helps you to find the route to your destination.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add route_guide
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install route_guide
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
You need to implement a server and a client. Then you can use this gem to connect between
|
18
|
+
the two.
|
19
|
+
|
20
|
+
### Server side service implementation
|
21
|
+
|
22
|
+
1. Create the service in `directions_service.rb`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'grpc'
|
26
|
+
require 'route_guide'
|
27
|
+
|
28
|
+
class DirectionsService < RouteGuide::DirectionsService::Service
|
29
|
+
def direct_it(direction_req, _unused_call)
|
30
|
+
puts "Received direction request for #{direction_req}"
|
31
|
+
RouteGuide::DirectionsResponse.new(
|
32
|
+
directions: response.direction,
|
33
|
+
approximate_time_of_travel_in_hrs: response.approximate_time_of_travel_in_hrs,
|
34
|
+
approximate_distance_in_kms: response.approximate_distance_in_kms
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
2. Setup the gRPC server in `server.rb`:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
#!/usr/bin/env ruby
|
44
|
+
|
45
|
+
require 'rubygems'
|
46
|
+
require 'route_guide'
|
47
|
+
require_relative 'directions_service'
|
48
|
+
|
49
|
+
class RouteGuideServer
|
50
|
+
class << self
|
51
|
+
def start
|
52
|
+
start_grpc_server
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def start_grpc_server
|
58
|
+
@server = GRPC::RpcServer.new
|
59
|
+
@server.add_http2_port("0.0.0.0:50052", :this_port_is_insecure)
|
60
|
+
@server.handle(DirectionsService)
|
61
|
+
@server.run_till_terminated
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
RouteGuideServer.start
|
67
|
+
```
|
68
|
+
|
69
|
+
3. Run server with;
|
70
|
+
|
71
|
+
```sh
|
72
|
+
bundle exec server.rb
|
73
|
+
```
|
74
|
+
|
75
|
+
### Client side
|
76
|
+
|
77
|
+
1. Do a client RPC call:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
#!/usr/bin/env ruby
|
81
|
+
|
82
|
+
require 'grpc'
|
83
|
+
require 'route_guide'
|
84
|
+
|
85
|
+
def test_single_call
|
86
|
+
stub = RouteGuide::DirectionsService::Stub.new('0.0.0.0:50052', :this_channel_is_insecure)
|
87
|
+
req = RouteGuide::DirectionsRequest.new(
|
88
|
+
current_location: 'current_location',
|
89
|
+
target_location: 'travel_location',
|
90
|
+
means_of_travel: 'means_of_travel'
|
91
|
+
)
|
92
|
+
resp_obj = stub.direct_it(req)
|
93
|
+
puts "Response: #{resp_obj}"
|
94
|
+
end
|
95
|
+
|
96
|
+
test_single_call
|
97
|
+
```
|
98
|
+
|
99
|
+
Then run the client in a separate terminal.
|
100
|
+
|
101
|
+
## Development
|
102
|
+
|
103
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
104
|
+
|
105
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
106
|
+
|
107
|
+
## Resources
|
108
|
+
|
109
|
+
- Building Micro-services using gRPC on Ruby
|
110
|
+
```
|
111
|
+
https://medium.com/@shiladitya16/building-micro-services-using-grpc-on-ruby-41acb755ee06
|
112
|
+
```
|
113
|
+
|
114
|
+
## Contributing
|
115
|
+
|
116
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Sylvance/route_guide.
|
117
|
+
|
118
|
+
## License
|
119
|
+
|
120
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/examples/client.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'grpc'
|
4
|
+
require 'route_guide'
|
5
|
+
|
6
|
+
def test_single_call
|
7
|
+
stub = RouteGuide::DirectionsService::Stub.new('0.0.0.0:50052', :this_channel_is_insecure)
|
8
|
+
req = RouteGuide::DirectionsRequest.new(
|
9
|
+
current_location: 'current_location',
|
10
|
+
target_location: 'travel_location',
|
11
|
+
means_of_travel: 'means_of_travel'
|
12
|
+
)
|
13
|
+
resp_obj = stub.direct_it(req)
|
14
|
+
puts "Response: #{resp_obj}"
|
15
|
+
end
|
16
|
+
|
17
|
+
test_single_call
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'grpc'
|
2
|
+
require 'route_guide'
|
3
|
+
|
4
|
+
class DirectionsService < RouteGuide::DirectionsService::Service
|
5
|
+
def direct_it(direction_req, _unused_call)
|
6
|
+
puts "Received direction request for #{direction_req}"
|
7
|
+
RouteGuide::DirectionsResponse.new(
|
8
|
+
directions: response.direction,
|
9
|
+
approximate_time_of_travel_in_hrs: response.approximate_time_of_travel_in_hrs,
|
10
|
+
approximate_distance_in_kms: response.approximate_distance_in_kms
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
data/examples/server.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'route_guide'
|
5
|
+
require_relative 'directions_service'
|
6
|
+
|
7
|
+
class RouteGuideServer
|
8
|
+
class << self
|
9
|
+
def start
|
10
|
+
start_grpc_server
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def start_grpc_server
|
16
|
+
@server = GRPC::RpcServer.new
|
17
|
+
@server.add_http2_port("0.0.0.0:50052", :this_port_is_insecure)
|
18
|
+
@server.handle(DirectionsService)
|
19
|
+
@server.run_till_terminated
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
RouteGuideServer.start
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: route_guide.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_file("route_guide.proto", :syntax => :proto3) do
|
8
|
+
add_message "route_guide.DirectionsRequest" do
|
9
|
+
optional :current_location, :string, 1
|
10
|
+
optional :target_location, :string, 2
|
11
|
+
optional :means_of_travel, :string, 3
|
12
|
+
end
|
13
|
+
add_message "route_guide.DirectionsResponse" do
|
14
|
+
optional :directions, :string, 1
|
15
|
+
optional :approximate_time_of_travel_in_hrs, :int32, 2
|
16
|
+
optional :approximate_distance_in_kms, :int32, 3
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module RouteGuide
|
22
|
+
DirectionsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("route_guide.DirectionsRequest").msgclass
|
23
|
+
DirectionsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("route_guide.DirectionsResponse").msgclass
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: route_guide.proto for package 'route_guide'
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require 'route_guide_pb'
|
6
|
+
|
7
|
+
module RouteGuide
|
8
|
+
module DirectionsService
|
9
|
+
class Service
|
10
|
+
|
11
|
+
include ::GRPC::GenericService
|
12
|
+
|
13
|
+
self.marshal_class_method = :encode
|
14
|
+
self.unmarshal_class_method = :decode
|
15
|
+
self.service_name = 'route_guide.DirectionsService'
|
16
|
+
|
17
|
+
rpc :direct_it, ::RouteGuide::DirectionsRequest, ::RouteGuide::DirectionsResponse
|
18
|
+
end
|
19
|
+
|
20
|
+
Stub = Service.rpc_stub_class
|
21
|
+
end
|
22
|
+
end
|
data/lib/route_guide.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package route_guide;
|
4
|
+
|
5
|
+
service DirectionsService {
|
6
|
+
rpc direct_it(DirectionsRequest) returns (DirectionsResponse) {}
|
7
|
+
}
|
8
|
+
|
9
|
+
message DirectionsRequest {
|
10
|
+
string current_location = 1;
|
11
|
+
string target_location = 2;
|
12
|
+
string means_of_travel = 3;
|
13
|
+
}
|
14
|
+
|
15
|
+
message DirectionsResponse {
|
16
|
+
string directions = 1;
|
17
|
+
int32 approximate_time_of_travel_in_hrs = 2;
|
18
|
+
int32 approximate_distance_in_kms = 3;
|
19
|
+
}
|
data/route_guide.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/route_guide/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "route_guide"
|
7
|
+
spec.version = RouteGuide::VERSION
|
8
|
+
spec.authors = ["sylvance_theone"]
|
9
|
+
spec.email = ["9350722+Sylvance@users.noreply.github.com"]
|
10
|
+
|
11
|
+
spec.summary = "Gem that demonstrates how to use gRPC in ruby."
|
12
|
+
spec.description = "Gem that demonstrates how to use gRPC in ruby."
|
13
|
+
spec.homepage = "https://github.com/Sylvance/route_guide"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/Sylvance/route_guide"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/Sylvance/route_guide/blob/main/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
spec.add_dependency "grpc"
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, check out our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
data/sig/route_guide.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: route_guide
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sylvance_theone
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grpc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Gem that demonstrates how to use gRPC in ruby.
|
28
|
+
email:
|
29
|
+
- 9350722+Sylvance@users.noreply.github.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- ".vscode/configurationCache.log"
|
37
|
+
- ".vscode/dryrun.log"
|
38
|
+
- ".vscode/settings.json"
|
39
|
+
- ".vscode/targets.log"
|
40
|
+
- CHANGELOG.md
|
41
|
+
- Gemfile
|
42
|
+
- Gemfile.lock
|
43
|
+
- LICENSE.txt
|
44
|
+
- Makefile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- examples/client.rb
|
48
|
+
- examples/directions_service.rb
|
49
|
+
- examples/server.rb
|
50
|
+
- lib/route_guide.rb
|
51
|
+
- lib/route_guide/route_guide_pb.rb
|
52
|
+
- lib/route_guide/route_guide_services_pb.rb
|
53
|
+
- lib/route_guide/version.rb
|
54
|
+
- proto/route_guide.proto
|
55
|
+
- route_guide.gemspec
|
56
|
+
- sig/route_guide.rbs
|
57
|
+
homepage: https://github.com/Sylvance/route_guide
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
allowed_push_host: https://rubygems.org
|
62
|
+
homepage_uri: https://github.com/Sylvance/route_guide
|
63
|
+
source_code_uri: https://github.com/Sylvance/route_guide
|
64
|
+
changelog_uri: https://github.com/Sylvance/route_guide/blob/main/CHANGELOG.md
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.6.0
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.1.4
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Gem that demonstrates how to use gRPC in ruby.
|
84
|
+
test_files: []
|