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

agreed-typed

 agreed-typed

2018/10/12 フューチャーアーキテクトとのLTバトルでの、伊藤の講演資料になります

Eea9a05e6e222a3d50c73f54a49fadf4?s=128

Recruit Technologies

October 12, 2018
Tweet

More Decks by Recruit Technologies

Other Decks in Technology

Transcript

  1. agreed-typed ҏ౻ɹӯ

  2. ࣗݾ঺հ • ҏ౻ɹӯʢ͍ͱ͏ɹ͖͋ͱʣ • @akito0107 • 2015೥ ϦΫϧʔτೖࣾ • ιϑτ΢ΣΞΤϯδχΞ

    • Go / Node.jsΛॻ͍͍ͯ·͢
  3. ͸ͳ͢͜ͱ • RTCͷΑ͋͘ΔΞʔΩςΫνϟ • AgreedͱConsumer-Driven Contract • Agreed-Typed • ·ͱΊ

  4. from: https://speakerdeck.com/yosuke_furukawa/rikurutotekufalserozizufalseji-shu-dong-xiang?slide=11

  5. None
  6. None
  7. ͜͜

  8. ͍ͭ΋ ͜͜Ͱ ݂͕ྲྀ ΕΔ

  9. APIͷI/Fʹؔ͢Δ໰୊ • ୭͕͍ܾͭΊΔ໰୊ • Backend͕উखʹܾΊͯFront͔Β͸࢖͍ͮΒ͍ (ex, N + 1 http

    requestͳͲ) • ϝϯςφϯεਏ͍໰୊ • DocumentͱͷෆҰகɺͦ΋ͦ΋DocͳͲͳ͍ɺ etc…
  10. Agreed • https://github.com/recruit-tech/agreed • Consumer-Driven Contract&Specification By Exampleͷπʔϧ • APIΛ࢖͏ଆʢFEʣ͕request

    / responseΛJSONͳͲͰ
 ࣗ༝ʹࢦఆͰ͖Δ • FEͷͨΊʹ͸Mock Serverͱͯ͠ৼΔ෣͏ • BEͷͨΊʹ͸E2E testing toolsͱͯ͠ৼΔ෣͏
  11. Agreed Sample • agreed.js

  12. Agreed Server Sample • Run Server • curl

  13. Agreed fileͷදݱྗͷ໰୊ • Agreed͸FE͕खܰʹmock serverΛཱͯΔͨΊͷ࢓૊Έ • Agreed fileΛਖ਼͘͠ॻ͘͜ͱࣗମ͕೉͍͠ • ex)

    ඞਢɾඇඞਢΛදݱͰ͖ͳ͍, ύϥϝʔλͷൈ͚͕ ݕ஌Ͱ͖ͳ͍ͳͲ • agreedͰrequest / responseΛఆٛͯ͠΋ɺFE/BEͰਖ਼ ͘͠ॲཧͰ͖ͯΔ͔Λ֬ೝ͢Δํ๏͕ͳ͍
  14. agreed-typed • Agreed fileͷAPIఆٛʹܕΛ͚ͭΔͨΊͷϥΠϒ ϥϦ • APIΛܕͰදݱ • requestͷPath΋ܕ, responseͷstatusCode΋ܕ

    • agreedͷఆٛΛ੩తղੳ͢Δ
  15. agreed-typed sample 1 • APIDef<>͔ΒͷܕΤΠϦΞεͰAPIΛఆٛ

  16. agreed-typed sample 2 • ܕʹैͬͯexampleΛఆٛ

  17. agreed-typed sample 3 • Run Server • curl

  18. agreed-typed sample 4 • ͍Ζ͍ΖͳܕνΣοΫΛ͔͚ΒΕΔ ະఆٛͷCPEZ ૝ఆ͞Εͳ͍
 TUBUVTDPEF QBUI͕ؒҧͬͯΔ

  19. ଞʹ΋ίϯύΠϥ͕νΣοΫͰ ͖Δ͜ͱ • GETʹbody͚ͭΔͱίϯύΠϥౖ͕Δ • Status codeʹΑΓbodyग़͠෼͚ • etc…

  20. Future of API design • Specification by example or 


    Specification by design • Consumer / Producerͷඇରশੑ • ܕͰAPIΛදݱ͠ɺਖ਼౰ੑΛίϯύΠϥ͕ݕূ͢Δ ੈք͕དྷΔ • Haskell servant / Protobuf
  21. ·ͱΊ • agreedͱconsumer driven contractͷ঺հ • agreed-typedͷ঺հ • APIఆٛΛܕͰදݱ͠Α͏

  22. ͋Γ͕ͱ͏͍͟͝·ͨ͠