-
Notifications
You must be signed in to change notification settings - Fork 25
第9回Go勉強会の課題@luccafort #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'grpc' | ||
require './proto/helloworld_services_pb' | ||
require './proto/notification_services_pb' | ||
|
||
# 通常のレスポンス | ||
http_client = Sample::Greeter::Stub.new( | ||
'127.0.0.1:5502', | ||
:this_channel_is_insecure | ||
) | ||
|
||
request_opts = Sample::HelloRequest.new(first_name: 'John', last_name: 'Doe') | ||
http_response = http_client.say_hello(request_opts) | ||
puts http_response | ||
|
||
puts '=====================' | ||
|
||
# Streamなレスポンスを受け取ったとき | ||
stream_client = Sample::Notifier::Stub.new( | ||
'127.0.0.1:5502', | ||
:this_channel_is_insecure | ||
) | ||
|
||
request_opts = Sample::HelloRequest.new(first_name: '太郎', last_name: '兼進') | ||
stream_request = stream_client.pereodic_hello(request_opts) | ||
stream_request.each { |req| puts req } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 今回、検証はしてないけどこの |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ファイルを分割しても良かったんですが元々Go側のコードも分割はしてなかったので1つのファイルで実行しています。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この標準出力は通常のレスポンスとStreamなレスポンスをわかりやすくする境界線として出力しているだけで特に意味はないです。