Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
gRPCとgrpc-gatewayを フル活用したweb開発
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Go Sagawa
December 04, 2019
Programming
93
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gRPCとgrpc-gatewayを フル活用したweb開発
Go Sagawa
December 04, 2019
More Decks by Go Sagawa
See All by Go Sagawa
GoのWebアプリ開発での DB関連トラブル
gosagawa
0
77
Errors Handling Talks at GopherCon2019
gosagawa
1
570
バッチとゴルーチンあるある
gosagawa
0
260
レガシーシステムあるある.pdf
gosagawa
0
380
Goを会社に導入して半年
gosagawa
0
130
20180228自社勉強会_プッシュ送信周りをマスターする
gosagawa
0
870
Other Decks in Programming
See All in Programming
スマート反転とウェブアクセシビリティ
camiha
0
180
高専キャリア LT 発表内容
crysta1221
6
5.6k
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
270
AIとGame Jamで、ゲームを完成させた話
takahirosaeki
0
120
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
120
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
590
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
230
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
180
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
3
500
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The Curse of the Amulet
leimatthew05
2
14k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
470
What's in a price? How to price your products and services
michaelherold
247
13k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
450
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
570
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Transcript
gRPCとgrpc-gatewayを フル活用したweb開発 golang.tokyo #28 Dec 4, 2019 Go Sagawa and
factory,inc. @go_sagawa
About me Go Sagawa Backend engineer and factory, inc. Smartphone
app Div Twitter : @go_sagawa
構成
今日話すこと • protoをどう作成するか • grpc-gatewayをどのように活用するか grpc-gatewayの活用方法 protoをどうやって作るか?
ケース1 機能で分ける 画面数50程のアプリに対し 大まかな機能毎に10数proto 1protoに2~8API 共通で使うものが数proto
ケース1 の問題点 クライアント側もprotoからコード生成したいが、 rpcの情報が邪 魔 上手く抽象化されず、複雑になってくる
抽象化してないもの
抽象化したもの
抽象化したもの Bは他でも使うの で共通に
抽象化したもの × 書き換えが多く発生 × Bが共通で使われない × 別のprotoでC’が作れられる × 名前がかぶる ×
依存関係がわかりにくい
解決するために protoの時点で 構造化を意識してみよう!
protoを上手く構造化する
protoを上手く構造化する
改良したproto構成 画面数50程のアプリに対し 大まかな機能毎にrpc用protoと画面protoが10数 モデルprotoが50程 rpc以外はクライアント側も利用してコード生成 画面protoは極力モデルを利用する
その他のtips フォーマッタとしてclang-format を活用する
その他のtips nilになる可能性のあるユーザ定義メッセージを明示 する
その他のtips grpc-gatewayで ゼロ値も出力するように設定しておく 参考:【grpc-gateway】0, false, nullなどの値をJSON出力対象にする Https://qiita.com/cpp0302/items/2450ee93e7c5fbec28a7
その他のtips レビューをクライアント側も交えて行う →全APIモックを作り切ってから実装に入っている Backend iOS android
共通proto protoで全て表現できるのは良いですが、スキーマからAPI仕様がしれなくなるのでアン チパターンなのではと思ってます。 共通のパラメータはgRPCのメタデータでやり取りするのが良いと思います。
grpc-gatewayの活用法 単にprotobufがjsonになってデバッグしやすくなる 事がメリットではない!
grpc-gatewayの活用法 ・net.httpを利用しており、同じようにミドルウェアが かける。
grpc-gatewayの活用法 ・ログイン以外のAPIを暗号化および複合する ・メンテナンス状態にして全APIをシャットアウトする ・バージョンを判断して、強制アップデートを促す ・外部サービス(広告サービスや各種ツール)から呼ばれる、通信方式がJSONでないリ クエストの対処 ・ヘルスチェック用のAPI提供
まとめ • protoは上手く構造化して抽象化するとより活用 しやすい • grpc-gatewayはmiddlewareを使うとより強力に なる