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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
400
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.7k
ChatGPTで僕が知っていることまとめ
hazumirr
3
3.1k
プロダクトチームとどう 協業し分析環境を改善するか
hazumirr
2
1.6k
Other Decks in Programming
See All in Programming
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
150
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
450
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
120
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
100
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
120
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
210
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
740
Lessons from Spec-Driven Development
simas
PRO
0
150
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
240
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.2k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
First, design no harm
axbom
PRO
2
1.2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
30 Presentation Tips
portentint
PRO
1
320
Building the Perfect Custom Keyboard
takai
2
790
RailsConf 2023
tenderlove
30
1.5k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
We Are The Robots
honzajavorek
0
240
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
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Ͱγϯϓϧʹ ଞͷαʔϏεͱͷίϛϡχέʔγϣϯָ͕ʹ ͕ඞཁ࠷খݶʹ