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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Go Sagawa
December 04, 2019
Programming
96
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
78
Errors Handling Talks at GopherCon2019
gosagawa
1
570
バッチとゴルーチンあるある
gosagawa
0
260
レガシーシステムあるある.pdf
gosagawa
0
380
Goを会社に導入して半年
gosagawa
0
130
20180228自社勉強会_プッシュ送信周りをマスターする
gosagawa
0
880
Other Decks in Programming
See All in Programming
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
120
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.7k
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.1k
Spec-driven Development with AI
simas
PRO
0
2.2k
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
120
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
690
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
320
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
330
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
5k
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
130
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
340
Featured
See All Featured
Between Models and Reality
mayunak
4
550
Practical Orchestrator
shlominoach
192
12k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
320
Why Our Code Smells
bkeepers
PRO
340
58k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
600
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
620
Discover your Explorer Soul
emna__ayadi
2
1.3k
The Cost Of JavaScript in 2023
addyosmani
55
10k
How to build a perfect <img>
jonoalderson
1
6.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.6k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
290
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を使うとより強力に なる