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
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
630
UIパーツの設計を「型」から読み解く 〜TSKaigiのセッションから得た学び〜
yud0uhu
0
540
未必のマクベス
yud0uhu
0
53
Webブラウザ向け動画配信プレイヤーの 大規模リプレイスから得た知見と学び
yud0uhu
0
420
早朝の渋谷の青さ、あるいは溺れた人を助ける為に飛び込んだ海の向こう側に見る、自己覚知と自己開示の尊さ
yud0uhu
1
1.1k
動画配信サービスのフロントエンド実装に学ぶ設計原則
yud0uhu
1
410
非デザイナーのフロントエンドエンジニアが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
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
290
速習iPhone Duo対応
yuukiw00w
2
960
mrbgem 三角測量 開発
ogom
0
200
iOSDC2026登壇資料.pdf
riofujimon
0
210
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
730
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
190
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
230
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
150
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
180
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
Heart of Swift Concurrency
koher
0
1.2k
Verilogで学ぶCPU自作入門.pdf
uyuki234
8
4k
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Product Roadmaps are Hard
iamctodd
55
13k
WCS-LA-2024
lcolladotor
0
840
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Test your architecture with Archunit
thirion
2
2.4k
The Language of Interfaces
destraynor
162
27k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
930
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
970
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
310
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
610
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