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
Rustでつくって学ぶProtocol Buffers
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yud0uhu
September 02, 2023
Programming
310
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rustでつくって学ぶProtocol Buffers
隅田川.dev vol.2 by Sep 2, 2023
yud0uhu
September 02, 2023
More Decks by yud0uhu
See All by yud0uhu
美しいコードを書くためにF#を学んでみた話
yud0uhu
1
580
UIパーツの設計を「型」から読み解く 〜TSKaigiのセッションから得た学び〜
yud0uhu
0
520
未必のマクベス
yud0uhu
0
49
Webブラウザ向け動画配信プレイヤーの 大規模リプレイスから得た知見と学び
yud0uhu
0
410
早朝の渋谷の青さ、あるいは溺れた人を助ける為に飛び込んだ海の向こう側に見る、自己覚知と自己開示の尊さ
yud0uhu
1
1k
動画配信サービスのフロントエンド実装に学ぶ設計原則
yud0uhu
1
400
非デザイナーのフロントエンドエンジニアがOOUIを考える
yud0uhu
9
6.1k
2023年の ゼロランタイムCSS in JS⚡️ を考える
yud0uhu
5
5.2k
Vue3/Electronで自作したマークダウンエディタをVue3/Tauriにリプレイスした話
yud0uhu
2
3.2k
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
220
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
200
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
120
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
110
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
230
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
110
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.4k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
300
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
650
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
290
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
160
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.8k
Fireside Chat
paigeccino
43
4k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
520
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
660
WCS-LA-2024
lcolladotor
0
820
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Six Lessons from altMBA
skipperchong
29
4.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
300
Transcript
Rustでつくって学ぶProtocol Buffers 隅田川.dev vol.2 1
自己紹介 • 名前:0yu(おゆ、ぜろゆー) • 出身:北海道 • 趣味:映画鑑賞・旅行・アニメ・趣味開発 etc • 最近はつけ麺と油そばに凝ってます
• Think ! FrontEnd by DMM #5 新卒会 [オンライン開催] 2 っっっz yud0uhu
3
gRPCとは 4 RPC(Remote Procedure Calll/遠隔手続き呼び出し)とは • 「クライアント−サーバー」の通信プロトコル ◦ サーバー上で実装されている関数(Procedure、プロシージャ)をクライアント からの呼び出しに応じて実行する技術
▪ サービス間通信のための新技術「gRPC」入門 | さくらのナレッジ
gRPCとは 5 RPCの問題点 • 広く普及している技術(HTTP/HTTPSやXML、JSON)を利用するため導入しやすい • テキストフォーマットなのでバイナリデータは扱いにくい • HTTP/HTTPSでのやりとりになるので、転送効率面のオーバーヘッドが大きい
gRPCとは 6 gRPCとは • RPCの問題点を解決するため、Googleによって開発されたRPCフレームワーク • 通信にHTTP/2、IDLにProtobuf(Protocol Buffers)を使用
gRPCとは 7 Protocol Buffersとは • Google謹製のデータフォーマットツール ◦ データを効率よく(バイナリデータも含む)扱える ◦ 構造化データをバイト列に変換(シリアライズ/デシリアライズ)するため、構造
化データを変換するためのスキーマ言語と捉えることもできる ▪ Understanding Protocol Buffers with Practical Examples | by Luis Soares | Medium
RustでgRPCサーバーを立てる 8 gRPCでチャットサーバーを立てる • 参考 ◦ helloworld-tutorial.md - hyperium/tonic ·
GitHub ◦ Example ◦ Chat System by Rust and gRPC-Web
RustでgRPCサーバーを立てる 9 tonicとは • RustでgRPCサーバを構築する場合、デファクトスタンダードなライブラリ
.protoファイルのsyntax highlightingを有効化 10 • vscode-proto3 - Visual Studio Marketplace
必要なライブラリのインストール 11 • protobuf — Homebrew Formulae ◦ tonicを動かすには、プロトコルバッファのコンパイラであるprotocが必要 •
grpcurl — Homebrew Formulae ◦ curlコマンドライクにgRPCサーバーとの対話を行うために必要
Protocol BufferでAPIを定義する 12
Protocol BufferでAPIを定義する 13 • syntax = "proto3" でバージョンを指定 • message型でスキーマを定義する
◦ 複数のフィールドを持つ ◦ それぞれのフィールドはスカラ型もしくはコンポジット型 • service型でgRPCのAPI定義をする
Cargo.toml に依存関係を記載 14
Build Scriptの定義 15 ビルド時にprotoファイルを読んで、gRPCのコードを自動生成するためのbuild.rsを書く
ビルドする:cargo buildする 16
ビルドする:target配下にRustのコードが自動生成される 17
サーバーを実装する 18
サーバーを実装する 19
サーバーを実装する 20
動作確認 21 carrog runでサーバーを起動
動作確認 22 →レスポンスが返ってくれば成功 grpcurl宛にprotoファイルを指定してリクエストを送る
最終的な実装 23 https://github.com/yud0uhu/grpc-chat