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
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
t0yohei
November 09, 2019
Technology
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Protocol Buffers で Web APIのスキーマ駆動開発がしたい
t0yohei
November 09, 2019
More Decks by t0yohei
See All by t0yohei
Vue の Input における State は親で持つべきか子で持つべきか
t0yohei
0
100
Vue.js を使って Grid System を実装した話
t0yohei
2
8k
負債が溜まったレガシーフロントエンド画面を Vue.js でリプレイスした話
t0yohei
0
2.3k
プログラミング入門に失敗した話
t0yohei
0
250
【ITエンジニアが怪我で労災!?】 仕事中に足の小指が骨折したら起きること
t0yohei
0
470
Ruby と JavaScript の違い( Function 編)
t0yohei
1
370
副業のノウハウ
t0yohei
0
220
ちょっとしたRubyの話
t0yohei
1
540
自作キーボード入門してみた
t0yohei
0
210
Other Decks in Technology
See All in Technology
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
740
Classmethod Company Deck
satoshi7
1
740
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
PRO
0
440
夫婦で子育てするための育児標準化
codmoninc
PRO
0
460
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
130
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
180
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
130
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
300
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
FinOps Agentが生んだ技術負債:コスト自動調査の落とし穴と解消までの道のり
oasis1994liveforever
2
150
価値について
gree_tech
PRO
0
110
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
480
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
540
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
420
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
Protocol Buffers で Web APIの スキーマ駆動開発がしたい (若手)エンジニアもくもく会 vol.19 @ビザスク authored
by t0yohei
Web API って • HTTP(S) のインターフェースで提供される API • SSKDs(Small Set
of Known Developers) ◦ Google Map の Geo API など • LSKDs(Large Set of Unknown Developers) ◦ サービス内でフロントエンドサーバーとバックエンドサーバーがやり取 りするための API など • REST, SOAP, gRPC, GraphQL などがある
スキーマ駆動開発って?
Web API の振る舞いの詳細を先に 決めて、 開発を進めていく手法のこと
こんなことありませんか? • フロントエンドの開発を進めたいけど、サーバーサイドからどんな json が 返ってくるかわからない • あるいは、予想してたのと違う json が返ってきた
解決方法: スキーマ駆動で開発する • APIを作る人・使う人が一緒にどういう API を作るのかを一緒に決めておく • フォーマットとしては、 Swagger(OpenAPI) など
• https://editor.swagger.io/
問題 • API の実装に変更があった時、ドキュメントがそれに合わせてメンテされる ことが保証できない • その結果、ドキュメントが正しいかわからなくなる • Swagger あんまり見やすくない(解釈)
我々が欲しいものは? • 定義したスキーマを元に、クライアント・サーバーで使用するコードを自動 生成してくれるもの • 可読性が高いもの
Protocol Buffers(protobuf)
Protocol Buffers(protobuf) って? • Google が開発してオープンソース化したスキーマ定義言語 • gRPCでよく使われている • proto
ファイルに実装した定義を元に、コードの自動生成が可能 • 読みやすい • 今さらProtocol Buffersと、手に馴染む道具の話 • Web API に秩序を与える Protocol Buffers / Protocol Buffers for Web API
protobuf を使うとどうなるのか • API の振る舞いを proto ファイルに定義 • サーバーサイド・フロントエンドの実装で基盤となるコードを自動生成 •
詳細な実装を追加 • 実装を変更する場合は proto ファイルを修正 • proto ファイルが仕様書になる
ちゃんと実装しました(まだ途中だけ ど)
作成したもの TODO リスト スキーマ定義: protobuf バックエンド: rails フロントエンド : nuxt.js
with TypeScript
直接コードを見てみる https://github.com/t0yohei/rails-nuxt-protobuf-todo
何が嬉しいか • スキーマ駆動で開発することができる • APIの修正時にドキュメント修正がいらない(実装が仕様になるので) • 静的言語だと、通信で受け取ったデータを parse した瞬間に型付けされる