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

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

D7b086b9c6bb828f15cd7a9ff9b8c688?s=128

Shintani Teppei

December 18, 2019
Tweet

Transcript

  1. 2.

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

    Wantedly new grads • Server side engineer • Wantedly Visit ืूػೳͷϚΠΫϩαʔϏεԽ • Ruby ❤ • ϚΠΫϩαʔϏεԽ΍͍͖ͬͯ
  2. 11.

    ©2019 Wantedly, Inc. grpc interceptorͱ͸ʁ ൚༻తͳgrpc interceptor grpc interceptor ͱ͸௨৴(rpcݺͼ

    ग़͠)ͷલޙͰಛఆͷॲཧΛ૊ΈࠐΊ Δػߏɻ express, rack middleware ͱ͍ͩ ͍ͨಉ͡ͱ͍͑͹఻ΘΔਓ͸఻ΘΔ ͔΋
  3. 12.

    ©2019 Wantedly, Inc. ࡞ͬͨ grpc interceptor ൚༻తͳgrpc interceptor • ΤϥʔΛ؂ࢹαʔϏεʹૹͬͯ͘ΕΔ͘Μ

    • Ruby/Rails ґଘͷΤϥʔΛ gRPC Τϥʔʹม׵͢Δ͘Μ • activerecord ͷ connection Λྑ͍ײ͡ʹ࢖͍ճ͘͢Μ •ΞΫηεϩάΛͱͬͯ೚ҙͷprovider΁ૹ৴͢Δ͘Μ by @south37 • newrelic ʹ metrics Λૹ৴ͯ͘͠ΕΔ͘Μ by @south37
  4. 13.

    ©2019 Wantedly, Inc. Protocol Buffersͷੑ࣭ ։ൃੜ࢈ੑ্͛ΔϥΠϒϥϦ • field ͸શͯ optional

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

    ©2019 Wantedly, Inc. Ruby gRPC best practice ͷ໛ࡧ • Rails

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

    ©2019 Wantedly, Inc. Ruby gRPC best practice ͷ໛ࡧ • Rails

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