grpc_kit 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/routeguide_client.rb +8 -15
- data/examples/routeguide_server.rb +7 -8
- data/lib/grpc_kit/grpc/logger.rb +1 -6
- data/lib/grpc_kit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c232e2a6300f194de5b0a503a9c9311a481b3f391ed5dcda373d155b0fce817
|
4
|
+
data.tar.gz: 87b46a793349f6af462b7be02101e691e2c2e2cb252b871b1322a453457f17e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 648fcb55a7244f237e10e677dd0a0f0a26f04e95e8d18494a8e53f137693d38e0820c069dc7cec6e400b29e40e81f7d8f1daab5d0fc02ffd337328e557c34dce
|
7
|
+
data.tar.gz: 53061fb0043f8a35cc8bc18c1da17547b23f6e865167a87c6f3e6fa00483c0af71a11880b29723d487f91de8687a1bb2207671e3af0d687582524743c62f1122
|
@@ -1,23 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Style/GlobalVars
|
4
|
-
|
5
3
|
$LOAD_PATH.unshift File.expand_path('./examples/routeguide')
|
6
4
|
|
7
5
|
require 'grpc_kit'
|
8
6
|
require 'pry'
|
9
7
|
require 'json'
|
10
|
-
require 'logger'
|
11
8
|
require 'routeguide_services_pb'
|
12
9
|
|
13
10
|
RESOURCE_PATH = './examples/routeguide/routeguide.json'
|
14
11
|
HOST = 'localhost'
|
15
12
|
PORT = 50051
|
16
13
|
|
17
|
-
$logger = Logger.new(STDOUT)
|
18
|
-
|
19
14
|
def get_feature(stub)
|
20
|
-
|
15
|
+
GRPC.logger.info('===== get_feature =====')
|
21
16
|
points = [
|
22
17
|
Routeguide::Point.new(latitude: 409_146_138, longitude: -746_188_906),
|
23
18
|
Routeguide::Point.new(latitude: 0, longitude: 0)
|
@@ -26,15 +21,15 @@ def get_feature(stub)
|
|
26
21
|
points.each do |pt|
|
27
22
|
feature = stub.get_feature(pt)
|
28
23
|
if feature.name == ''
|
29
|
-
|
24
|
+
GRPC.logger.info("Found nothing at #{feature.inspect}")
|
30
25
|
else
|
31
|
-
|
26
|
+
GRPC.logger.info("Found '#{feature.name}' at #{feature.location.inspect}")
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
30
|
|
36
31
|
def list_features(stub)
|
37
|
-
|
32
|
+
GRPC.logger.info('===== list_features =====')
|
38
33
|
rect = Routeguide::Rectangle.new(
|
39
34
|
lo: Routeguide::Point.new(latitude: 400_000_000, longitude: -750_000_000),
|
40
35
|
hi: Routeguide::Point.new(latitude: 420_000_000, longitude: -730_000_000),
|
@@ -44,12 +39,12 @@ def list_features(stub)
|
|
44
39
|
|
45
40
|
loop do
|
46
41
|
r = stream.recv
|
47
|
-
|
42
|
+
GRPC.logger.info("Found #{r.name} at #{r.location.inspect}")
|
48
43
|
end
|
49
44
|
end
|
50
45
|
|
51
46
|
def record_route(stub, size)
|
52
|
-
|
47
|
+
GRPC.logger.info('===== record_route =====')
|
53
48
|
|
54
49
|
features = File.open(RESOURCE_PATH) do |f|
|
55
50
|
JSON.parse(f.read)
|
@@ -79,14 +74,14 @@ ROUTE_CHAT_NOTES = [
|
|
79
74
|
].freeze
|
80
75
|
|
81
76
|
def route_chat(stub)
|
82
|
-
|
77
|
+
GRPC.logger.info('===== route_chat =====')
|
83
78
|
|
84
79
|
call = stub.route_chat({})
|
85
80
|
|
86
81
|
t = Thread.new do
|
87
82
|
loop do
|
88
83
|
rn = call.recv
|
89
|
-
|
84
|
+
GRPC.logger.info("Got message #{rn.message} at point point(#{rn.location.latitude}, #{rn.location.longitude})")
|
90
85
|
end
|
91
86
|
end
|
92
87
|
|
@@ -115,5 +110,3 @@ get_feature(stub)
|
|
115
110
|
list_features(stub)
|
116
111
|
record_route(stub, 10)
|
117
112
|
route_chat(stub)
|
118
|
-
|
119
|
-
# rubocop:enable Style/GlobalVars
|
@@ -6,13 +6,11 @@ require 'grpc_kit'
|
|
6
6
|
require 'pry'
|
7
7
|
require 'json'
|
8
8
|
require 'routeguide_services_pb'
|
9
|
-
require 'logger'
|
10
9
|
|
11
10
|
class Server < Routeguide::RouteGuide::Service
|
12
11
|
RESOURCE_PATH = './examples/routeguide/routeguide.json'
|
13
12
|
|
14
13
|
def initialize
|
15
|
-
@logger = Logger.new(STDOUT)
|
16
14
|
File.open(RESOURCE_PATH) do |f|
|
17
15
|
features = JSON.parse(f.read)
|
18
16
|
@features = Hash[features.map { |x| [x['location'], x['name']] }]
|
@@ -23,12 +21,12 @@ class Server < Routeguide::RouteGuide::Service
|
|
23
21
|
|
24
22
|
def get_feature(point, ctx)
|
25
23
|
name = @features.fetch({ 'longitude' => point.longitude, 'latitude' => point.latitude }, '')
|
26
|
-
|
24
|
+
GRPC.logger.info("Point longitude=#{point.longitude}, latitude=#{point.latitude}, metadata=#{ctx.metadata}")
|
27
25
|
Routeguide::Feature.new(location: point, name: name)
|
28
26
|
end
|
29
27
|
|
30
28
|
def list_features(rect, stream)
|
31
|
-
|
29
|
+
GRPC.logger.info('===== list_features =====')
|
32
30
|
|
33
31
|
@features.each do |location, name|
|
34
32
|
if name.nil? || name == '' || !in_range(location, rect)
|
@@ -37,13 +35,13 @@ class Server < Routeguide::RouteGuide::Service
|
|
37
35
|
|
38
36
|
pt = Routeguide::Point.new(location)
|
39
37
|
resp = Routeguide::Feature.new(location: pt, name: name)
|
40
|
-
|
38
|
+
GRPC.logger.info(resp)
|
41
39
|
stream.send_msg(resp)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
43
|
def record_route(stream)
|
46
|
-
|
44
|
+
GRPC.logger.info('===== record_route =====')
|
47
45
|
distance = 0
|
48
46
|
count = 0
|
49
47
|
features = 0
|
@@ -52,7 +50,7 @@ class Server < Routeguide::RouteGuide::Service
|
|
52
50
|
|
53
51
|
loop do
|
54
52
|
point = stream.recv # XXX: raise StopIteration
|
55
|
-
|
53
|
+
GRPC.logger.info(point)
|
56
54
|
|
57
55
|
count += 1
|
58
56
|
name = @features.fetch({ 'longitude' => point.longitude, 'latitude' => point.latitude }, '')
|
@@ -75,7 +73,7 @@ class Server < Routeguide::RouteGuide::Service
|
|
75
73
|
def route_chat(call)
|
76
74
|
loop do
|
77
75
|
rn = call.recv
|
78
|
-
|
76
|
+
GRPC.logger.info("route_note location=#{rn.location.inspect}, message=#{rn.message}")
|
79
77
|
key = "#{rn.location.latitude} #{rn.location.longitude}"
|
80
78
|
saved_msgs = @route_notes[key]
|
81
79
|
@route_notes[key] << rn.message
|
@@ -117,6 +115,7 @@ class Server < Routeguide::RouteGuide::Service
|
|
117
115
|
end
|
118
116
|
|
119
117
|
sock = TCPServer.new(50051)
|
118
|
+
GrpcKit.logger = Logger.new('hoge', level: :debug)
|
120
119
|
|
121
120
|
opts = {}
|
122
121
|
|
data/lib/grpc_kit/grpc/logger.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
|
5
3
|
module GrpcKit
|
6
4
|
module GRPC
|
7
5
|
module DefaultLogger
|
8
|
-
# @return [Logger]
|
9
6
|
def logger
|
10
|
-
|
7
|
+
GrpcKit.logger
|
11
8
|
end
|
12
|
-
|
13
|
-
LOGGER = Logger.new(STDOUT)
|
14
9
|
end
|
15
10
|
|
16
11
|
unless methods.include?(:logger)
|
data/lib/grpc_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ganmacs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ds9
|