Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails から Protobuf を使いたくなった話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hazumi Ichijo
September 20, 2018
Programming
2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails から Protobuf を使いたくなった話
銀座Rails#1
https://ginza-rails.connpass.com/event/97820/
Hazumi Ichijo
September 20, 2018
More Decks by Hazumi Ichijo
See All by Hazumi Ichijo
RailsとRidgepoleの マイグレを120倍早くする
hazumirr
0
420
CIを整備してメンテナンスを生成AIに任せる
hazumirr
0
1.5k
病院の情報フローを理解して、 予約〜会計の見え方が変わった話
hazumirr
1
1.9k
Rubyのコード削除したい時 僕がやること
hazumirr
0
280
テーブル駆動テストと状態
hazumirr
5
2.2k
オンラインテストしようと思った その日に開始できる環境を目指して
hazumirr
0
1.1k
推薦によるプロダクト改善とマイクロサービスが噛み合った話
hazumirr
2
4.8k
ChatGPTで僕が知っていることまとめ
hazumirr
3
3.1k
プロダクトチームとどう 協業し分析環境を改善するか
hazumirr
2
1.6k
Other Decks in Programming
See All in Programming
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
480
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.8k
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
5.7k
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
140
act2-costs.pdf
sumedhbala
0
110
AIエージェントで 変わるAndroid開発環境
takahirom
2
490
【やさしく解説 設計編 #1】「ドメイン駆動」と「実装駆動」ってなに? 〜設計の考え方を、たとえ話で学ぼう〜
panda728
PRO
1
110
Webフレームワークの ベンチマークについて
yusukebe
0
200
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
350
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
370
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
170
Between Models and Reality
mayunak
4
370
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Docker and Python
trallard
47
3.9k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Product Roadmaps are Hard
iamctodd
55
12k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
Unsuck your backbone
ammeep
672
58k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Transcript
©2018 Wantedly, Inc. Rails͔ΒProtobufΛ ͍ͨ͘ͳͬͨ Cloud Pub/Sub ͰͷεΩʔϚཧ 2018.9.20 -
@rerost/@hazumirr
©2018 Wantedly, Inc. ࣗݾհ Ұᑍ!IB[VNJSS!SFSPTU 8FC"QQMJDBUJPO&OHJOFFS 3BJMT (P 3FBDUʜ ۴࿏ߴઐஜେֶ8BOUFEMZ
©2018 Wantedly, Inc. ۴࿏ߴઐ
©2018 Wantedly, Inc. 8BOUFEMZ1FPQMF ϦϦʔε ϚΠΫϩαʔϏεʢ(P 3VCZ ʜʣ
8BOUFEMZ7JTJU ϦϦʔε ϞϊϦγοΫͳ3BJMTΞϓϦέʔγϣϯ
©2018 Wantedly, Inc. ืू ϑΟʔυ εΧτ
©2018 Wantedly, Inc.
©2018 Wantedly, Inc. ຖશͯͷεΧτ༻ͷϢʔβʔσʔλΛೖΕ͍ͯ͠Δ ࠩͷσʔλ͚ͩཉ͍͠ WJTJUࣗମͷ։ൃͱผαΠΫϧͰճ͍ͨ͠ σʔλੳ෦ #JH2VFSZͳͲΛѻ͏
©2018 Wantedly, Inc. վળํ๏ ͪΐͬͱͣͭվળ͍ͯ͘͠ ϚΠΫϩαʔϏεʹΓग़͢
©2018 Wantedly, Inc. εΧτͷػೳ ߜΓࠐΈ ਪન Ϣʔβʔใͷදࣔ
ϚΠΫϩαʔϏεʹΓग़ͯ͠ ཧ͍ͨ͠
©2018 Wantedly, Inc. εΧτͷσʔλੳ͢Δਓ
©2018 Wantedly, Inc. ͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ
©2018 Wantedly, Inc. 7JTJUͷ͕͍
©2018 Wantedly, Inc. ͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ ௨ͯ͘͠ΕΔԿ͔
©2018 Wantedly, Inc. $MPVE1VC4VC
©2018 Wantedly, Inc. https://cloud.google.com/pubsub/docs/overview
©2018 Wantedly, Inc. ͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ
©2018 Wantedly, Inc. ϝϦοτ αʔϏε͕ؒૄ݁߹ʹͳΔ σϝϦοτ ૹΔσʔλεΩʔϚͷཧ͕͍͠
©2018 Wantedly, Inc. ͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ
©2018 Wantedly, Inc. ͦ͜Ͱ1SPUPDPM#V⒎FS γϦΞϥΠβʔɾσγϦΞϥΠβʔࣗಈੜ ޓੑ͕͋ΔఔอͨΕΔ ੩తܕ͖ݴޠͰ͏·͘ѻ͑Δ
ࣾͷଞͷνʔϜ͕͍ͬͯͯݟ͕͋Δ
©2018 Wantedly, Inc. ͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ 1SPUPCVG 1SPUPCVG
©2018 Wantedly, Inc. Protocol Buffer
©2018 Wantedly, Inc. syntax = "proto3"; option ruby_package = "Protos::SamplePB";
message User { // ֶྺ message Education { string school_name = 1; } // ৬ྺ message Experience { string company_name = 1; } string user_name = 1; string introduction = 2; int64 age = 3; repeated Education educations = 4; repeated Experience experiences = 5; } TBNQMFQSPUP
©2018 Wantedly, Inc. # Generated by the protocol buffer compiler.
DO NOT EDIT! # source: protos/sample.proto require 'google/protobuf' Google::Protobuf::DescriptorPool.generated_pool.build do add_message "User" do optional :user_name, :string, 1 optional :introduction, :string, 2 optional :age, :int64, 3 repeated :educations, :message, 4, "User.Education" repeated :experiences, :message, 5, "User.Experience" end add_message "User.Education" do optional :school_name, :string, 1 end add_message "User.Experience" do optional :company_name, :string, 1 end end module Protos::SamplePB User = Google::Protobuf::DescriptorPool.generated_pool.lookup("User").msgclass User::Education = Google::Protobuf::DescriptorPool.generated_pool.lookup("User.Education").msgclass User::Experience = Google::Protobuf::DescriptorPool.generated_pool.lookup("User.Experience").msgclass end TBNQMFQCSC
©2018 Wantedly, Inc. def new_sample educations = [ Protos::SamplePB::User::Education.new( school_name:
"۴࿏ߴઐ" ), Protos::SamplePB::User::Education.new( school_name: "ஜେֶ" ), ] experiences = [ Protos::SamplePB::User::Experience.new( company_name: "ΥϯςουϦʔגࣜձࣾ" ), ] Protos::SamplePB::User.new( user_name: 'rerost', introduction: 'δϟεί͔Β110km', educations: educations, experiences: experiences, ) end sample = new_sample puts Protos::SamplePB::User.encode_json(sample) { "userName": "rerost", "introduction": "δϟεί͔Β110km", "educations": [ { "schoolName": "۴࿏ߴઐ" }, { "schoolName": "ஜେֶ" } ], "experiences": [ { "companyName": "ΥϯςουϦʔגࣜձࣾ" } ] }
©2018 Wantedly, Inc. def new_sample Protos::SamplePB::User.new( user_name: 1, # Τϥʔ
user_nameͷܕ͕ҧ͏ͷͰ age: 23, introduction: 'δϟεί͔Β110km', educations: [], experiences: [], ) end sample = new_sample ҧ͏ܕΛೖΕͨ߹ʹ͍ͭͯ
©2018 Wantedly, Inc. def new_sample Protos::SamplePB::User.new() end sample = new_sample
puts sample.age # 0 ΛೖΕͳ͔ͬͨ߹ʹ͍ͭͯ
©2018 Wantedly, Inc. def new_sample Protos::SamplePB::User.new( age: 23, ) end
sample = new_sample encoded = Protos::SamplePB::User.encode(sample) puts encoded.class # String decoded = Protos::SamplePB::User.decode(encoded) puts decoded.age # 23 CJOBSZͷγϦΞϥΠζσγϦΞϥΠζ
©2018 Wantedly, Inc. def new_sample Protos::SamplePB::User.new( age: 23, ) end
sample = new_sample encoded = Protos::SamplePB::User.encode_json(sample) puts encoded.class # String puts encoded # {"age":23,"educations":[],"experiences":[]} decoded = Protos::SamplePB::User.decode_json(encoded) puts decoded.age # 23 +40/ͷγϦΞϥΠζσγϦΞϥΠζ
©2018 Wantedly, Inc. https://github.com/rerost/sample-protobuf
©2018 Wantedly, Inc. ޓੑʹ͍ͭͯ ࠷ݶཉ͍͠ޓੑɹ ΧϥϜͷՃ ໊લͷมߋ
©2018 Wantedly, Inc. ޓੑʹ͍ͭͯ ࠷ݶཉ͍͠ޓੑɹ ΧϥϜͷՃ ໊લͷมߋ 1SPUPCVGͳΒɾɾɾ
σγϦΞϥΠζෆՄͳΧϥϜແࢹ λάφϯόʔͰࣝผ όΠφϦͳΒ
©2018 Wantedly, Inc. <࠶ܝ>͠ϚΠΫϩαʔϏεԽ͕ਐΜͩΒ 1SPUPCVG 1SPUPCVG
©2018 Wantedly, Inc. 1SPUPCVGΛ͏͜ͱͰղܾͰ͖ͨɹ σʔλΛ҆ఆͯ͠ΓऔΓͰ͖Δ ੩తܕ͖ݴޠͱ͏·͘ΓͱΓ͕Ͱ͖Δ γϦΞϥΠβʔσγϦΞϥΠβʔ͕ࣗಈੜͰ͖Δ
©2018 Wantedly, Inc. 1SPUPCVGPO1VC4VCͰγϯϓϧʹ ଞͷαʔϏεͱͷίϛϡχέʔγϣϯָ͕ʹ ͕ඞཁ࠷খݶʹ