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

Advanced API Calling in Go

Advanced API Calling in Go

Go 1.9 Release Party in Tokyo での発表資料です by @__timakin__

Seiji Takahashi

August 22, 2017
Tweet

More Decks by Seiji Takahashi

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • Github: timakin / Twitter: @__timakin__ • ŧŔŕŪ Go

    Ŭ Contribute ŢŦ • Gunosy ৽نࣄۀ։ൃࣨ ॴଐ • Go / Swift • Recently Contributed / Created • giginet/xcprofiler • mercari/gaurun • timakin/gopli • timakin/ssm2env • timakin/md2mid • timakin/gonvert
  2. Copyright© Gunosy Inc. All Rights Reserved 3 Go / Python

    ΤϯδχΞืूத ▶https://gunosy.co.jp/recruit/ Gunosy͸ɺ౦ژେֶʹ௨͏3ਓͷֶੜͷ
 ʮ৘ใΛੈքதͷਓʹ࠷దʹಧ͚͍ͨʯͱ͍͏૝͍͔Β࢝·Γ·ͨ͠ɻ ౦ূϚβʔζ্৔ɺ࿡ຊ໦ώϧζ΁ͷΦϑΟεҠసΛܦͯɺ
 େ͖͘੒௕͍ͯ͠ΔձࣾͰ׆༂͍ͨ͠ϝϯόʔΛืू͍ͯ͠·͢ɻ
  3. goroutineͰͷฒߦcall • Goॻ͍ͯΔΜ͔ͩΒɺෳ਺ճAPIίʔϧ
 ͢Δ৔߹͸΋ͪΖΜgoroutine࢖͍͍ͨ • ྫʣtimakin/ssm2env • AWS (EC2 Parameter

    Store)ʹอଘ͞Ε͍ͯΔ
 ಛఆͷKeyʹͻ΋ͮ͘ValueΛऔ͖ͬͯͯɺ
 ݁ՌΛmapʹೖΕ͍ͨ • Ͱ΋10ݸ͔ͣͭ͠औಘͰ͖ͳ͍

  4. Proxy • GoͷHTTPϦΫΤετͷߏ੒ཁૉ • http.RoundTripper • HTTPͷτϥϯβΫγϣϯΛ࣮ߦ͠ɺreq/resΛॲཧ͢Δ ͨΊͷΠϯλʔϑΣʔε • http.Transport

    • http.RoundTripper Λ࣮૷ͨ͠ߏ଄ମͰɺ௨৴ʹඞཁͳ ઃఆͱɺRoundTripϝιουͷ࣮૷Λ࣋ͭ
  5. Proxy • GoͷHTTPϦΫΤετͷߏ੒ཁૉ • http.RoundTripper • HTTPͷτϥϯβΫγϣϯΛ࣮ߦ͠ɺreq/resΛॲཧ͢Δ ͨΊͷΠϯλʔϑΣʔε • http.Transport

    • http.RoundTripper Λ࣮૷ͨ͠ߏ଄ମͰɺ௨৴ʹඞཁͳ ઃఆͱɺRoundTripϝιουͷ࣮૷Λ࣋ͭ • http.Client • http.Transport Λ಺෦ʹ࣋ͬͨɺHTTPϓϩτίϧͰͷ௨ ৴Λ͓͜ͳ͏ͨΊͷૉͷΫϥΠΞϯτ࣮૷ • func (c *Client) Do(…) ͸தͰRoundTripΛݺΜͰ͍Δ