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

HTTP クライアントを作ろうとして学ぶ、使いやすいインタフェース / #GoCon_Sen...

HTTP クライアントを作ろうとして学ぶ、使いやすいインタフェース / #GoCon_Sendai 2020

Masayuki Izumi

October 10, 2020
Tweet

More Decks by Masayuki Izumi

Other Decks in Programming

Transcript

  1. ©2020 Wantedly, Inc. @izumin5210 Backend Chapter Lead, Profile Domain Wantedly,

    Inc. ‣ #BDLFOEͷ5FDI-FBEతͳ͜ͱΛ͍ͯ͠·͢ ‣ ੜ࢈ੑΛ্͛Δந৅ɾϑϨʔϜϫʔΫΛݟ͚ͭΔͷ͕޷͖Ͱ͢ ‣ ࠷ۙͷ͓͖ʹ͍Γύοέʔδ  ▶HPMBOHPSHYUPPMTHPQBDLBHFTQBDLBHFTUFTU  HPPHMFHPMBOHPSHQSPUPCVGSFqFDUQSPUPSFqFDU  HJUIVCDPNWFLUBIHRMQBSTFS  !UFTUJOHMJCSBSZSFBDUIPPLT
  2. ©2020 Wantedly, Inc. ‣ 0CTFSWBCJMJUZͷͨΊͷϑοΫ  .FUSJDT -PHT 5SBDFT ʜ

     ΞΫηεϩά ‣ ద੾ͳʓʓઓུͷӅṭ  Ωϟογϡ ϦτϥΠ λΠϜΞ΢τ ʜ lͪΌΜͱz)551ϦΫΤετ͢Δͷ͸೉͍͠ 1SPEVDUJPO3FBEJOFTTͷ؍఺ ‣ ڞ௨ϩδοΫͷ࣮૷  "VUI/ "VUI; ʜ ‣ ࢖͍΍͍͢"1*  ৑௕ͳهड़͕ݮΒͤΔ  ͍Ζ͍Ζ๨Εͳ͍  ʜ lศརϥΠϒϥϦzͱͯ͠ͷ؍఺
  3. ©2020 Wantedly, Inc. ‣ 0CTFSWBCJMJUZͷͨΊͷϑοΫ  .FUSJDT -PHT 5SBDFT ʜ

     ΞΫηεϩά ‣ ద੾ͳʓʓઓུͷӅṭ  Ωϟογϡ ϦτϥΠ λΠϜΞ΢τ ʜ lͪΌΜͱz)551ϦΫΤετ͢Δͷ͸೉͍͠ 1SPEVDUJPO3FBEJOFTTͷ؍఺ ‣ ڞ௨ϩδοΫͷ࣮૷  "VUI/ "VUI; ʜ ‣ ࢖͍΍͍͢"1*  ৑௕ͳهड़͕ݮΒͤΔ  ͍Ζ͍Ζ๨Εͳ͍  ʜ lศརϥΠϒϥϦzͱͯ͠ͷ؍఺ ʮ࠷ڧͷ IUUQ$MJFOUίϯετϥΫλʯͰ ղܾ͢Δ΋ͷ΋ଟ͍
  4. ©2020 Wantedly, Inc. ‣ 0CTFSWBCJMJUZͷͨΊͷϑοΫ  .FUSJDT -PHT 5SBDFT ʜ

     ΞΫηεϩά ‣ ద੾ͳʓʓઓུͷӅṭ  Ωϟογϡ ϦτϥΠ λΠϜΞ΢τ ʜ lͪΌΜͱz)551ϦΫΤετ͢Δͷ͸೉͍͠ 1SPEVDUJPO3FBEJOFTTͷ؍఺ ‣ ڞ௨ϩδοΫͷ࣮૷  "VUI/ "VUI; ʜ ‣ ࢖͍΍͍͢"1*  ৑௕ͳهड़͕ݮΒͤΔ  ͍Ζ͍Ζ๨Εͳ͍  ʜ lศརϥΠϒϥϦzͱͯ͠ͷ؍఺ ͜ͷลͷʮࣄނΓ΍͢͞ʯ͸ʁ -JOUͰղܾͰ͖Δ΋ͷ΋͋Δ͕ʜ ʢFHUJNBLJOCPEZDMPTF TPOBUBSEOPDUYʣ
  5. ©2020 Wantedly, Inc. 3FBM8PSME)5513FRVFTU ‣ ඞཁͳ࡞ۀ͸࿙Εͯͳ͍͔ʁ  DPOUFYU$POUFYUΛ఻ൖͤͯ͞ͳ͍ͱɺϝτϦΫε΍τϨʔε͕औΕͳ͘ͳΔ  4UBUVTDPEF͕YY΍YYͰ΋A

    IUUQ$MJFOU %PA͸ΤϥʔΛฦ͞ͳ͍  ʜ ‣ ҙ֎ͱ᠘͕ଟ͍ʂ  -JOUͰΧόʔͰ͖Δ΋ͷ΋͋ΔʢFHUJNBLJOCPEZDMPTF TPOBUBSEOPDUYʣ lͪΌΜͱz)551ϦΫΤετ͢Δͷ͸೉͍͠
  6. ©2020 Wantedly, Inc. AOFUIUUQ$MJFOUA͸ྑ͘ͳ͍ʁ ‣ ͦΜͳ͜ͱ͸ͳ͍ʂ  ϝδϟʔέʔεͰ͋Δʮ+40/ͷԟ෮ʯʹ͸͔ͨ͠ʹ৑௕͔΋͠Εͳ͍  ҰํͰɺඪ४ϥΠϒϥϦͳͷͰଟ༷ͳχʔζʹରԠͰ͖Δඞཁ͕͋Δ

     )551ͷ௨৴ࣗମ͕੒ޭ͍ͯ͠ΔͷͰYYͰ΋Τϥʔ͡Όͳ͍ͷ΋Θ͔Δ  ετϦʔϜతͳ΍͔ͭ΋͠Εͳ͍ͷͰ<>CZUFͰ͸ͳ͘JP3FBEFSͳͷ΋Θ͔Δ ‣ ΋ͷ͝ͱͷҰଆ໘͚ͩΛݟͯྑ͠ѱ͠Λ൑ఆ͢Δͷ͸μϝ  ʮͳͥͦ͏ͳ͍ͬͯΔ͔ʯΛߟ͑ͯΈΔͷ͕େ੾ ίϥϜతͳ࿩
  7. ©2020 Wantedly, Inc. APIs should be easy to use and

    hard to misuse. Joshua Bloch: Bumper-Sticker API Design* * https://www.infoq.com/articles/API-Design-Joshua-Bloch/ lྑ͍ΠϯλϑΣʔεzͱ͸
  8. ©2020 Wantedly, Inc. $IBSBDUFSJTUJDTPGB(PPE"1* ‣ &BTZUPMFBSO ‣ &BTZUPVTF FWFOXJUIPVUEPDVNFOUBUJPO ‣

    )BSEUPNJTVTF ‣ &BTZUPSFBEBOENBJOUBJODPEFUIBUVTFTJU ‣ &BTZUPFYUFOE ‣ "QQSPQSJBUFUPBVEJFODF lྑ͍ΠϯλϑΣʔεzͱ͸ * “How to design a good API and why it matters” ͔ΒҾ༻ https://research.google/pubs/pub32713/
  9. ©2020 Wantedly, Inc. ‣ &BTZUPMFBSO&BTZUPVTF FWFOXJUIPVUEPDVNFOUBUJPO  ࢖͍ํΛ༰қʹֶ΂Δ  υΩϡϝϯτΛಡ·ͳͯ͘΋ɺʢิ׬ީิɾΠϯλϑΣʔεΛݟΕ͹ʣͰ࢖͑Δ

    ‣ )BSEUPNJTVTF  FHʮDPOUFYU$POUFYU౉͠๨ΕʯʮIUUQTUBUVTνΣοΫ͠๨Εʯ͕ى͖ͳ͍Α͏ͳ࢓૊Έɾ*' ‣ &BTZUPFYUFOE  FHʮʓʓͷͨΊͷϑοΫΛ࢓ࠐΉʯΈ͍ͨͳͷ͕༰қʹ࢓ࠐΊΔΑ͏ͳ &BTZUPVTF)BSEUPNJTVTFͳ)551ΫϥΠΞϯτ * “How to design a good API and why it matters” ͔ΒҾ༻ https://research.google/pubs/pub32713/
  10. ©2020 Wantedly, Inc. BYJPT ϒϥ΢βɾ/PEFKTͰ࢖͑Δ+4ϥΠϒϥϦ ‣ ϦΫΤετͷ౤͛ํ͸໌շ  )551.FUIPE+4ͷϝιου໊ 

    YY YYͩͱ&SSPS͕UISPX͞ΕΔ ‣ *OUFSDFQUPSͱ͍͏ܗͰϦΫΤετલޙʹ հೖͰ͖ΔΑ͏ʹͳ͍ͬͯΔ ଞͷݴޠͰͷ)551ΫϥΠΞϯτ
  11. ©2020 Wantedly, Inc. 'BSBEBZ (JU)VCDMJFOUͰ΋ར༻͞ΕΔ3VCZHFN ‣ ϦΫΤετͷ౤͛ํ͸BYJPTͱ΄΅ಉ͡  )551.FUIPEϝιου໊ 

    YY YYͩͱ&SSPS͕UISPX͞ΕΔ ‣ .JEEMFXBSFΛ࣮૷ɾએݴ͢Δ͜ͱͰɺ
 ϦΫΤετલޙʹհೖͰ͖Δ ଞͷݴޠͰͷ)551ΫϥΠΞϯτ
  12. ©2020 Wantedly, Inc. ‣ )551.FUIPE໊͕ͦͷ··ϝιου໊ʹͳͬͯΔέʔε͕ଟ͍  ʮ)551$MJFOUΠϯελϯεͷϝιουʯύλʔϯʢ'BSBEBZ BYJPTʣ  ʮ3FRVFTUΦϒδΣΫτͷCVJMEFSQBUUFSOʯύλʔϯʢ0L)UUQ

    3FRVFTUTʣ ‣ YY YYͷॲཧํ਑͸େ͖̎͘௨Γ  Τϥʔʹ͢ΔBYJPT 'BSBEBZʢWҎ߱ʣ  AJT4VDDFTTAͱ͔APLAΈ͍ͨͳϝιου0L)UUQ 'BSBEBZʢ;Δ͍΍ͭʣ ‣ ϦΫΤετͷલޙʹॲཧΛڬΊΔΑ͏ʹͳ͍ͬͯΔʢ*OUFSDFQUPS .JEEMFXBSFʣ ‣ #BTF63-ΛઃఆͰ͖Δ΋ͷ΋ଟ͍ ଞͷݴޠ͔ΒΘ͔Δ͜ͱ
  13. ©2020 Wantedly, Inc. HJUIVCDPNJ[VNJOIYݱࡏͷܗ ‣ ❓&BTZUPMFBSO ‣ ❓&BTZUPVTF FWFOXJUIPVUEPDVNFOUBUJPO ‣

    ❓)BSEUPNJTVTF ‣ ❓&BTZUPSFBEBOENBJOUBJODPEFUIBUVTFTJU ‣ ❓&BTZUPFYUFOE ‣ ❓"QQSPQSJBUFUPBVEJFODF
  14. ©2020 Wantedly, Inc. HJUIVCDPNJ[VNJOIYݱࡏͷܗ ‣ ❓&BTZUPMFBSO ‣ ❓&BTZUPVTF FWFOXJUIPVUEPDVNFOUBUJPO ‣

    ✅)BSEUPNJTVTF ‣ ❓&BTZUPSFBEBOENBJOUBJODPEFUIBUVTFTJU ‣ ✅&BTZUPFYUFOE ‣ ❓"QQSPQSJBUFUPBVEJFODF
  15. ©2020 Wantedly, Inc. HJUIVCDPNJ[VNJOIYݱࡏͷܗ ‣ ❓&BTZUPMFBSO ‣ ❓&BTZUPVTF FWFOXJUIPVUEPDVNFOUBUJPO ‣

    ✅)BSEUPNJTVTF ‣ ❓&BTZUPSFBEBOENBJOUBJODPEFUIBUVTFTJU ‣ ✅&BTZUPFYUFOE ‣ ❓"QQSPQSJBUFUPBVEJFODF ‣ .JTVTF͸͔ͳΓݮΔͷͰ͸ʁ  ΫϥΠΞϯτ͕ԿΛฦ͔͕ࣗ͢໌  ΫϥΠΞϯτڞ௨ͷৼΔ෣͍ΛࢦఆͰ͖Δ  YYYY΋ΤϥʔʹͳΔ ‣ &BTZUPMFBSOVTF͸Ͳ͏ͩΖ͏ʁ  $POEJUJPOBM3FTQPOTF)BOEMFSͷ
 ྑ͍υΩϡϝϯτɾ&YBNQMFΛఏڙͰ͖Δ͔
  16. ©2020 Wantedly, Inc. "1*εΩʔϚ͔Βͷίʔυੜ੒ ‣ 0QFO"1* 4XBHHFS ͔Β)551ΫϥΠΞϯτͷίʔυΛੜ੒͢Δͱ͍͏Ξϓϩʔν  HJUIVCDPNHPTXBHHFSHPTXBHHFS

    ‣ TUSVDUΛड͚औΓTUSVDUΛฦؔ͢਺͕ੜ·ΕΔͷͰɺར༻·Ͱͷোน͸গͳ͍ ‣ εΩʔϚʢ࢓༷ॻʣ͔ΒίʔυΛੜ੒͢ΔͷͰNJTVTF΋ى͖ͮΒ͍ εΩʔϚۦಈ։ൃɺྑͦ͞͏ʹݟ͑Δ ଞͷlྑ͍ΠϯλϑΣʔεz࣮ݱख๏
  17. ©2020 Wantedly, Inc. Real World Migration from HTTP to gRPC

    in Ruby #grpcconf https://speakerdeck.com/south37/real-world-migration-from-http-to-grpc-in-ruby-number-grpcconf
  18. ©2020 Wantedly, Inc. ॕH31$׬શຊ൪౤ೖ Real World Migration from HTTP to

    gRPC in Ruby #grpcconf https://speakerdeck.com/south37/real-world-migration-from-http-to-grpc-in-ruby-number-grpcconf
  19. ©2020 Wantedly, Inc. ৽نʹॻ͔ΕΔ"1*͸͢΂ͯH31$ʹ ʢ)551ΫϥΠΞϯτͷग़൪͕ΊͬͪΌݮͬͨʣ Real World Migration from HTTP

    to gRPC in Ruby #grpcconf https://speakerdeck.com/south37/real-world-migration-from-http-to-grpc-in-ruby-number-grpcconf
  20. ©2020 Wantedly, Inc. ͳͥH31$͸lྑ͍z͔ ‣ ໌շͳ*%-ʹΑΔεΩʔϚఆٛ ‣ Α͋͘ΔϓϩάϥϛϯάݴޠͬΆ͍4ZOUBYͰ ಡΉͱ͖ͷෛՙ͕௿͍ ‣

    ʮΠϯσϯτϛεͬͯҙਤ͠ͳ͍εΩʔϚʹʯ Έ͍ͨͳ:".-͋Δ͋Δࣄނ͸ى͖ͳ͍ ‣ ʮಠࣗݴޠʯ͸σϝϦοτͱ΋ݴ͑Δ͕ɺ
 1SPUPCVG*%-͸े෼޿͘࢖ΘΕ͍ͯΔ͸ͣ lྑ͍ΠϯλϑΣʔεzͱ͍͏ࢹ఺ͰͷH31$
  21. ©2020 Wantedly, Inc. ͪΌΜͱͨ݁͠࿦ ‣ l$IBSBDUFSJTUJDPGB(PPE"1*zͱଞݴޠͷ)551ΫϥΠΞϯτ͔Βɺ
 ࢖͍΍͍͢)551ΫϥΠΞϯτʢ+40/"1*ΫϥΠΞϯτʣͷܗΛ໛ࡧͨ͠ ‣ Α͋͘Δʮ࢖͍΍͍͢)551ΫϥΠΞϯτʯΛຬͨ͢Α͏ɺ(PͰ)551ΫϥΠΞϯτΛ࣮૷ͨ͠ 

    3FBMXPSMEBQQMJDBUJPOͰར༻Ͱ͖ΔΑ͏ɺ)BSEUPNJTVTF&BTZUPFYUFOEʹؾΛ࢖ͬͯΈͨ  HJUIVCDPNJ[VNJOIY ‣ ݴޠɾϑϨʔϜϫʔΫɾϓϩτίϧ໰Θͣɺʮྑ͍ΠϯλϑΣʔεʯͷΤοηϯε͸ಉ͡
 ΞϯςφΛ޿͘ுͬͯٵऩ͍͚ͯ͠Δͱڧ͍෢ثʹͳΔ ‣ H31$ʢྑ͍εΩʔϚఆٛݴޠͱɺ͔ͦ͜Βੜ੒͞ΕΔྑ͍ΠϯλϑΣʔεͷίʔυʣ͸ਆ