Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Ruby gRPCを使って「ちゃんと」サービスを作る / Make a service pro...

Ruby gRPCを使って「ちゃんと」サービスを作る / Make a service properly using Ruby gRPC

Shintani Teppei

December 18, 2019
Tweet

More Decks by Shintani Teppei

Other Decks in Technology

Transcript

  1. ©2019 Wantedly, Inc. About me Teppei Shintani @euglena1215 • ’19

    Wantedly new grads • Server side engineer • Wantedly Visit ืूػೳͷϚΠΫϩαʔϏεԽ • Ruby ❤ • ϚΠΫϩαʔϏεԽ΍͍͖ͬͯ
  2. ©2019 Wantedly, Inc. grpc interceptorͱ͸ʁ ൚༻తͳgrpc interceptor grpc interceptor ͱ͸௨৴(rpcݺͼ

    ग़͠)ͷલޙͰಛఆͷॲཧΛ૊ΈࠐΊ Δػߏɻ express, rack middleware ͱ͍ͩ ͍ͨಉ͡ͱ͍͑͹఻ΘΔਓ͸఻ΘΔ ͔΋
  3. ©2019 Wantedly, Inc. ࡞ͬͨ grpc interceptor ൚༻తͳgrpc interceptor • ΤϥʔΛ؂ࢹαʔϏεʹૹͬͯ͘ΕΔ͘Μ

    • Ruby/Rails ґଘͷΤϥʔΛ gRPC Τϥʔʹม׵͢Δ͘Μ • activerecord ͷ connection Λྑ͍ײ͡ʹ࢖͍ճ͘͢Μ •ΞΫηεϩάΛͱͬͯ೚ҙͷprovider΁ૹ৴͢Δ͘Μ by @south37 • newrelic ʹ metrics Λૹ৴ͯ͘͠ΕΔ͘Μ by @south37
  4. ©2019 Wantedly, Inc. Protocol Buffersͷੑ࣭ ։ൃੜ࢈ੑ্͛ΔϥΠϒϥϦ • field ͸શͯ optional

    • proto2 Ͱ͸ required field ͕ଘࡏ͕ͨ͠ɺproto3Ͱ͸શͯ optional ʹͳͬͨ • required ͳ field Λഇࢭͨ͘͠ͳͬͨͱ͖ʹޙํޓ׵Λҡ࣋͢Δͷ͕೉͍͠ ΞϓϦέʔγϣϯଆͷϩδοΫͰ null ͔Ͳ͏͔ΛνΣοΫ͢Δඞཁ͕͋Δ ΊͪΌͪ͘Ό໘౗
  5. ©2019 Wantedly, Inc. Ruby gRPC best practice ͷ໛ࡧ • Rails

    ͷ஌ݟΛ Ruby gRPC ʹͲ͏ྲྀ༻͢Δ͔ • Rails controller ʹґଘ͍ͯ͠Δ gem ͸Ұ௨Γ࢖͑ͳ͍ • ͲΜͳઃܭʹ͢Δͱ͍͍ͷ͔ʁ • Rails Έ͍ͨʹ DB table ͱ API interface Λີ݁߹ͤͨ͘͞ͳ͍ • MVVM? Ͳ͜·Ͱ΍Δʁ
  6. ©2019 Wantedly, Inc. Ruby gRPC best practice ͷ໛ࡧ • Rails

    ͷ஌ݟΛ Ruby gRPC ʹͲ͏ྲྀ༻͢Δ͔ • Rails controller ʹґଘ͍ͯ͠Δ gem ͸Ұ௨Γ࢖͑ͳ͍ • ͲΜͳઃܭʹ͢Δͱ͍͍ͷ͔ʁ • Rails Έ͍ͨʹ DB table ͱ API interface Λີ݁߹ͤͨ͘͞ͳ͍ • MVVM? Ͳ͜·Ͱ΍Δʁ ͜͜ͷ݁࿦͸·ͩग़͍ͯͳ͍ɺɺɺ