Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gRPC入門
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Taiga Sakaguchi
November 19, 2022
Technology
0
270
gRPC入門
Taiga Sakaguchi
November 19, 2022
Tweet
Share
More Decks by Taiga Sakaguchi
See All by Taiga Sakaguchi
トランクベース開発のすすめ
taigaskg
0
130
クリーンアーキテクチャのすすめ
taigaskg
0
330
Other Decks in Technology
See All in Technology
Tebiki Engineering Team Deck
tebiki
0
24k
今日から始めるAmazon Bedrock AgentCore
har1101
4
400
生成AI時代にこそ求められるSRE / SRE for Gen AI era
ymotongpoo
5
3k
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
160
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.2k
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
300
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
150
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
200
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
160
プロダクト成長を支える開発基盤とスケールに伴う課題
yuu26
4
1.3k
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
520
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
230
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
200
From π to Pie charts
rasagy
0
120
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
92
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
410
RailsConf 2023
tenderlove
30
1.3k
Building AI with AI
inesmontani
PRO
1
690
How to Talk to Developers About Accessibility
jct
2
130
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Site-Speed That Sticks
csswizardry
13
1.1k
Transcript
gRPC 入門 Taiga Sakaguchi 1
Sakaguchi Taiga 教員→Web エンジニア 歴3 年 バックエンドエンジニア 都内メガベンチャーに勤務 2
gRPC とは Google によって開発されたRPC フレームワーク 3
RPC とは Remote Procedure Call の頭字語(遠隔手続き呼び出し) ネットワークを通じて別のコンピュータ上で動作するソフトウェア の関数を呼び出すための仕様 4
一般的な関数呼び出し 5
RPC における関数呼び出し 6
RPC の何が嬉しいのか ローカルの関数かリモートの関数かを意識せずにコードを書くこと ができる 7
type Server struct {} type User struct{ ID string }
func (s *Server) GetUser(id string) *User {} type Client struct {} func (c *Client)DoSomething() { u := c.GetUser("userid") } 8
REST だったら type Server struct {} func main() { r
:= gin.Default() r.GET("/user/:id", getUser) r.Run() } func getUser(c *gin.Context) {} type Client struct {} func (c *Client) DoSomething() { resp, err := http.Get("http://user/1") } 9
https://grpc.io/docs/what-is-grpc/introduction/ 10
Protocol Buffers Google により開発 IDL (インターフェース定義言語) 通信や永続化での利用を目的としたシリアライズフォーマット コードやDocs など自動生成できる 11
syntax = "proto3"; service User { rpc GetUser(GetUserRequest) returns (GetUserResponse)
{} } message GetUserRequest { string id = 1; } message GetUserResponse { string id = 1; string name = 2; } 12
サーバー用の生成コード // ... type UserServer interface { GetUser(context.Context, *GetUserRequest) (*GetUserResponse,
error) mustEmbedUnimplementedUserServer() } // ... 13
クライアント用の生成コード // ... type UserClient interface { GetUser(ctx context.Context, in
*GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) } func NewUserClient(cc grpc.ClientConnInterface) UserClient { return &userClient{cc} } // ... 14
ここでクイズ gRPC の「g 」の意味はなんでしょうか? 1. Google 2. Good 3. Great
4. Game 15
ここでクイズ gRPC の「g 」の意味はなんでしょうか? 1. Google 2. Good 3. Great
4. Game 16
gRPC の「g 」はバージョンごとに意味がかわるらしい https://github.com/grpc/grpc/blob/master/doc/g_stands_for.md 17
gRPC のメリット HTTP/2 で通信 Protocol Buffers によるシリアライズ ストリーミング処理 多くの言語に対応(Go, Java,
Kotlin, Node, PHP, Python, Ruby,... ) 18
4 つの通信方式 Unary RPC Server streaming RPC Client streaming RPC
Bidirectional streaming PRC 19
Unary RPC 1 Request - 1 Response 20
Server streaming RPC 1 Request - N Response 例)push 通知など
21
Client streaming RPC N Request - 1 Response 例)データを分割して複数回に分けてアップロード 22
Bidirectional streaming PRC WebSocket のような双方向通 例) チャット 23
gRPC のデメリット PRC の設計に気をつけないと破綻する 実装に時間がかかる ブラウザでのサポートが十分でない 24
gRPC が向いているケース Microservice プライベートなAPI モバイル、IoT 25
ブラウザ - サーバー間で導入するには grpc-web grpc-gateway connect 26
grpc-web 27
grpc-gateway 28
connect https://connect.build/ 29
connect 30
参考 https://grpc.io/ https://zenn.dev/hsaki/books/golang-grpc-starting https://christina04.hatenablog.com/entry/2017/11/13/190000 https://qiita.com/gold-kou/items/a1cc2be6045723e242eb 31
32