examples/routeguide_server.rb in griffin-0.1.4 vs examples/routeguide_server.rb in griffin-0.1.5
- old
+ new
@@ -18,10 +18,11 @@
@route_notes = Hash.new { |h, k| h[k] = [] }
end
def get_feature(point, ctx)
+ GRPC.logger.info('===== get_feature =====')
name = @features.fetch({ 'longitude' => point.longitude, 'latitude' => point.latitude }, '')
GRPC.logger.info("Point longitude=#{point.longitude}, latitude=#{point.latitude}, metadata=#{ctx.metadata}")
Routeguide::Feature.new(location: point, name: name)
end
@@ -46,12 +47,11 @@
count = 0
features = 0
start_at = Time.now.to_i
last = nil
- loop do
- point = stream.recv # XXX: raise StopIteration
+ stream.each do |point|
GRPC.logger.info(point)
count += 1
name = @features.fetch({ 'longitude' => point.longitude, 'latitude' => point.latitude }, '')
unless name == ''
@@ -69,12 +69,12 @@
elapsed_time: Time.now.to_i - start_at,
)
end
def route_chat(call)
- loop do
- rn = call.recv
+ GRPC.logger.info('===== record_chat =====')
+ call.each do |rn|
GRPC.logger.info("route_note location=#{rn.location.inspect}, message=#{rn.message}")
key = "#{rn.location.latitude} #{rn.location.longitude}"
saved_msgs = @route_notes[key]
@route_notes[key] << rn.message
@@ -118,9 +118,14 @@
c.bind '127.0.0.1'
c.port 50051
c.services Server.new
+
+ if ENV['GRPC_INTERCEPTOR']
+ require_relative 'interceptors/server_logging_interceptor'
+ c.interceptors [LoggingInterceptor.new]
+ end
c.workers 2
end
Griffin::Server.run