Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gRPC入門

To Kawa
December 01, 2019

 gRPC入門

To Kawa

December 01, 2019
Tweet

More Decks by To Kawa

Other Decks in Technology

Transcript

  1. GoݴޠͰgRPCʹೖ໳ͯ͠Έͨ

    View full-size slide

  2. ࣗݾ঺հ
    Տ༢ढ़ً

    גࣜձࣾLIFULL 

    CoEϢχοτ։ൃਪਐάϧʔϓॴଐ

    ৽ଔ1೥໨

    ڵຯͷ͋Δ෼໺

    ɾϒϩοΫνΣʔϯ

    ɾFintech

    ݴޠ

    Node/Solidity/PHP/Apex/Go


    View full-size slide

  3. gRPCͱ͸Կ͔
    • Google͕։ൃͨ͠RPCݺग़ϓϩτίϧ

    • ϝοηʔδ͸ProtocolBuffersΛ༻͍ͯ௨৴

    • HTTP/2Λ༻͍ͯฒྻݺग़ɺ૒ํ޲ݺग़ɺετϦʔϛϯά
    ͳͲ͕Մೳ

    • .protoϑΝΠϧ͔Βίʔυ͕ࣗಈੜ੒Ͱ͖Δ

    • GoogleͷαʔϏεͰ΋࣮ࡍʹ࢖ΘΕ͍Δ

    View full-size slide

  4. gRPCͱ͸Կ͔
    ΫϥΠΞϯτͱαʔόͰෳ਺ͷݴޠΛαϙʔτ͍ͯ͠Δ

    →ϚΠΫϩαʔϏεͳͲͱ૬ੑ͕͍͍

    View full-size slide

  5. 4ͭͷRPCํࣜ
    • Unary(Simple)

    →1 request-1 response

    • ServerStreaming

    →1 request-N response

    • ClientStreaming

    →N request-1 response

    • BidirectionalStreaming

    →N request-N response

    View full-size slide

  6. ϝϦοτ
    • REST APIΑΓURLઃܭָ͕

    →protoϑΝΠϧͰAPI࢓༷Λ໌จԽͰ͖Δ

    →දଆͱཪଆ͕࢓༷ͷ͢Γ߹Θָ͕ͤ

    • HTTP/2Ͱฒྻݺग़ͳͲ͕Ͱ͖ΔͨΊɺߴ଎

    • ύϥϝʔλʔͷܕ෇͚͕Ͱ͖Δ

    View full-size slide

  7. ࡞੒ͷྲྀΕ
    1. protoϑΝΠϧͷ࡞੒

    2. ᶃͰ࡞੒ͨ͠ϑΝΠϧΛίϯύΠϧͯ͠ɺࣗಈͰ਽ܗ
    ίʔυΛੜ੒

    3. ਽ܗίʔυΛݩʹαʔόʔˍΫϥΠΞϯτΛ࣮૷͢Δ

    View full-size slide

  8. ࣮ࡍʹ΍ͬͯΈΔ

    (Ұ൪γϯϓϧͳUnary)

    View full-size slide

  9. protoϑΝΠϧ࡞੒

    View full-size slide

  10. ίϚϯυ࣮ߦ

    View full-size slide

  11. ίϚϯυͰੜ੒͞ΕΔ਽ܗϑΝΠϧ
    https://github.com/waytkheming/calculator-proto/blob/master/proto/calculator.pb.go

    View full-size slide

  12. MongoDBΛ࢖ͬͯCUIͷTwitterΈ͍ͨͳͷΛ࡞ͬͯΈͨ
    https://github.com/waytkheming/gwitter-proto

    View full-size slide

  13. ࢀߟURL
    • gRPC Documentation

    https://grpc.io/docs/

    • ΫοΫύου͕gRPCΛ࠾༻͢Δ·ͰαʔϏεؒ௨৴Ͱ๊͑ͯ
    ͍ͨ՝୊ͱɺRubyͰgRPCΛӡ༻͢ΔͨΊͷ޻෉

    https://logmi.jp/tech/articles/320715

    • gRPCͬͯԿʁ

    https://qiita.com/oohira/items/63b5ccb2bf1a913659d6

    • gRPCʹ͓͚ΔRPCํࣜͷ੔ཧ

    https://qiita.com/yuzo777/items/046910c95559cf0fff68

    View full-size slide

  14. Gopherಓ৔ͷײ૝

    View full-size slide

  15. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·͠
    ͨɻ

    View full-size slide