Next Currency-GAEGo

3cb4e761dbdb7aebd1ffd85f752e1e3e?s=47 sonata
January 29, 2018

Next Currency-GAEGo

3cb4e761dbdb7aebd1ffd85f752e1e3e?s=128

sonata

January 29, 2018
Tweet

Transcript

  1. 1 /FYU$VSSFODZͱ("&(P HPMBOHUPLZP !TPOBUBSE

  2. Server Side Engineer ͦͳͨ @sonatard • University • Linux Server

    and Network Engineer • Canon • Develop Wireless LAN Module Simulator with SystemC • Develop TCP/IP protocol stack on RTOS • Go in my free time • Mercari/Souzoh • Google App Engine Go Engineer • Mercari Atte • Next Currency • Google App Engine Go Engineer
  3. • ຊ ೔ ͷ ࿩ • N C ͷ ٕ

    ज़ બ ఆ
  4. 4 ຊ೔ͷ࿩ w ελʔτΞοϓͰ͸("&(P͕͍͍ w Φʔτεέʔϧ w εϐϯΞοϓ͕ૣ͍ w 04ͷ؅ཧ͕ෆཁ

    w ϓϩμΫτͷ։ൃʹूதͰ͖Δ w ࣮ࡍʹ࢖ͬͯΈͯ w ΍͸Γศར w ݕ౼͕ඞཁͳϙΠϯτ͸ଟ͍
  5. 5 ຊ೔ͷ࿩ w ελʔτΞοϓΤϯδχΞ͕গͳ͍ w ϓϩμΫτͷ։ൃɺಛʹࠩผԽཁҼ͚ͩʹूத͍ͨ͠ w ϓϩμΫτͷ։ൃ w ΠϯϑϥͷΞʔΩςΫνϟ

    w ։ൃ؀ڥ w σϓϩΠ؀ڥ w $*؀ڥ w ςετ ϑϨʔϜϫʔΫɺॻ͖ํ  w ϑϨʔϜϫʔΫ΍ϥΠϒϥϦͷબఆ w ηΩϡϦςΟ w ΞϓϦέʔγϣϯͷΞʔΩςΫνϟݕ౼ w %#ͷઃܭ w "1*ͷઃܭ w ϏδωεϩδοΫͷίʔσΟϯά w ϏδωεϩδοΫΛ༻͍ͯΞϓϦέʔγϣϯΛߏங͢Δίʔυ w ΫϥΠΞϯτνʔϜ޲͚ͷυΩϡϝϯτ w ϩάղੳ
  6. 6 ελʔτΞοϓʹ͓͚Δ։ൃ w ελʔτΞοϓͱͯ͠/$͕ࣾͲͷΑ͏ʹ("&(PΛར༻͠ɺͲͷΑ͏ʹߟٕ͑ͯज़બఆΛ ͖͔ͯͨ͠Λ঺հ͠·͢ɻ

  7. • ຊ ೔ ͷ ࿩ • N C ͷ ٕ

    ज़ બ ఆ
  8. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  9. 9 ٕज़બఆͷجຊํ਑ w ˓4JNQMF w ʷ&BTZ w ඞཁҎ্ʹརศੑΛ͋͛ΔͨΊʹϑϨʔϜϫʔΫ΍ϥΠϒϥϦΛ࠾༻͠ͳ͍ w ϑϨʔϜϫʔΫΛ࠾༻͢Δ͜ͱͰɺཧղ͕༰қʹͳΔ΋ͷΛ࠾༻͢Δɻ

    w ˓4JNQMF w ίʔυͷهड़Λ୹͘͢ΔͳͲɺ࡞ۀྔΛݮΒ͢͜ͱΛ໨తͱͨ͠΋ͷ͸࠾༻͠ͳ͍ɻ w ʷ&BTZ
  10. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  11. 11 ϓϩδΣΫτͷߏ੒ w ("&4&Ͱ͸ͭͷΞϓϦέʔγϣϯ͝ͱʹͭͷϓϩδΣΫτΛ࡞Δ w /$Ͱ͸ɺຊ൪ɺ2"ɺ։ൃऀ͝ͱͷݸਓ։ൃ؀ڥͷछྨ

  12. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  13. 13 αʔϏεͷߏ੒ w αʔϏε w ("&4&Ͱ͸αʔϏεͱ͍͏୯ҐͰΞϓϦέʔγϣϯΛ෼ׂՄೳ w αʔϏεͷ୯ҐͰΠϯελϯε͕࡞੒͞ΕΔ w αʔϏε͝ͱʹεέʔϧ

    w αʔϏε͝ͱʹΠϯελϯεͷछྨΛબ୒ w $16ɺϝϞϦͷαΠζ͕ҟͳΔ BQJ CBUDI BVUI BQJ BQJ YYY
  14. 14 αʔϏεͷߏ੒ w -ωοτϫʔΫ͸("&4&Ͱ͸ߟ͑Δඞཁ͸ͳ͍ w *1ΞυϨεΛҙࣝ͢Δ͜ͱ͸ͳ͍ w ("&ͷαʔϏε͝ͱʹࣗಈతʹυϝΠϯׂ͕ΓৼΒΕΔ w IUUQTαʔϏε໊EPUϓϩδΣΫτ໊BQQTQPUDPN

    w αʔϏεͱಠࣗʹऔಘͨ͠υϝΠϯΛඥ͚ͮΔ͜ͱ͕Մೳ BQJ BVUI BQJ BQJ YYY IUUQTBQJFYBNQMFDPN IUUQTBQJEPUQSPKFDUBQQTQPUDPN
  15. 15 αʔϏεͷߏ੒ w /$Ͱ͸.JDSPTFSWJDFTͰ͸ͳ͍͕ɺαʔϏεͷ෼ׂΛ͍ͯ͠Δ w ιʔείʔυ͸શαʔϏεڞ௨ w αʔϏεؒͰͷ௨৴͸جຊతʹͳ͠ɺϢʔβ͔ΒͷೖΓޱ͚ͩΛ෼͚͍ͯΔ w /$ͰͷαʔϏεͷར༻໨త

    w εέʔϧΞοϓͷ୯ҐɺΠϯελϯεͷೳྗ w ։ൃ༻ w EFCVHαʔϏε͸ຊ൪ʹ͸σϓϩΠ͠ͳ͍ w ೝূͷ༗ແ w BENJOαʔϏε͸ɺ(PPHMFΞΧ΢ϯτͷೝূ͕ඞཁ w αʔϏε͝ͱʹσϓϩΠ͕ඞཁʹͳΔͷͰɺ෼͚͗͢ΔͱσϓϩΠʹ͕͔͔࣌ؒΔΑ͏ ʹͳΔͷͰ஫ҙ
  16. 16 αʔϏεͷߏ੒ w ೝূͷৄࡉ app.yaml handlers: - url: /.* #

    ೝূ͋Γ login :required # HTTPSඞਢ secure: always func login(w http.ResponseWriter, r *http.Request) { ctx := appengine.NewContext(r) u := user.Current(ctx) if u == nil { url, _ := user.LoginURL(ctx, "/") fmt.Fprintf(w, `<a href="%s">Sign in or register</a>`, url) return } url, _ := user.LogoutURL(ctx, "/") fmt.Fprintf(w, `Welcome, %s! (<a href="%s">sign out</a>)`, u, url) }
  17. 17 αʔϏεͷߏ੒ w .JDSPTFSWJDFTͷඞཁੑ w ʮΦʔφʔγοϓΛ࣋ͭͨΊʯͱ͍͏ࢦ਑͸ͱͯ΋͍͍ w "1*࢓༷͑͞ڞ༗͢Ε͹ɺͦͷ಺෦ͷٕज़બఆ͸ࣗ༝ʹͳΔ w ιʔείʔυɺ"1*ͷϓϩτίϧɺ%#ͳͲ

    w ػೳʹ߹Θͤͨద੾ͳٕज़બఆ͕Մೳ w "*ج൫ͳΒ1ZUIPOɺ"1*ͳΒ(P w ෳ਺ͷαʔϏε͔Βڞ௨ج൫Λར༻Ͱ͖ΔΑ͏ʹͳΔ w ೝূɺϩά w .JDSPTFSWJDFTΛ࠾༻͢Δฐ֐ w ݕ౼ཁૉ͕૿͑Δ w ίʔυϦϙδτϦΛαʔϏε͝ͱʹ෼ׂ͢Δ΂͖͔ w ෼ׂͨ͠৔߹ɺڞ௨υϝΠϯͷมߋΛͲͷΑ͏ʹ؅ཧ͢Δ͔ w ֤αʔϏεͷϩάͷ؅ཧ͸Ͳ͏͢Δ͔
  18. 18 αʔϏεͷߏ੒ w /$ͱͯ͠͸.JDSPTFSWJDFTΛ࠾༻͍ͯ͠ͳ͍ w શһ͕ΦʔφʔγοϓΛ࣋ͯΔ૊৫ن໛Ͱ͋ΔͨΊ෼ׂ͸ඞཁͳ͍ w কདྷΛ૝ఆͨ͠ڞ௨ج൫Λਖ਼͘͠ࣄલʹઃܭ͢Δ͜ͱ͸ࠔ೉ w γεςϜ͕૊৫ʹґଘ͢Δ͜ͱ΋ϦεΫ

    w େن໛ͳมߋࢪࡦΛଧͭͨΊʹ͸ɺ૊৫Λԣஅ͢Δඞཁ͕Ͱͯ͘Δ w ෦෼࠷దʹ͍ؕΔՄೳੑ w ΠϊϕʔγϣϯͷδϨϯϚͰ͸ϦεΫͱͯ͠঺հ͞Ε͍ͯΔ w ੡඼ͷઃܭ͕૊৫ਤͦͷ΋ͷ w ՄೳͳݶΓগਓ਺ͰɺγϯϓϧͰϞϊϦγοΫͳγεςϜΛӡ༻͍͖͍ͯͨ͠ w .JDSPTFWJDFT͸໨ࢦ͢΋ͷͰ͸ͳ͘ඞཁʹഭΒΕͨΒऔΔ΂͖બ୒ࢶͷͭ
  19. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  20. 20 σϓϩΠ w ("&ͷσϓϩΠํ๏ w αʔϏε͝ͱʹσϓϩΠΛ͢Δ w ࢦఆͨ͠όʔδϣϯͷΠϯελϯε͕࡞੒͞Εɺ63-͕ൃߦ͞ΕΔ w IUUQT\όʔδϣϯ^EPU\αʔϏε^EPU\ϓϩδΣΫτ^BQQTQPUDPN

    w όʔδϣϯ୯ҐͰCMVFHSFFOEFWFMPQNFOUΛ࣮ݱ͢Δػೳ͕ඪ४Ͱ༻ҙ w τϥϑΟοΫͷׂ߹Λࢦఆͯ͠੾Γସ͑ΒΕΔɺϩʔϧόοΫ΋༰қ w gcloud app deploy --version=${vers} ${ayml}
  21. 21 σϓϩΠ w /$ͰͷόʔδϣϯͷܾΊํ w ։ൃத͸ɺϒϥϯν໊ w σϓϩΠ͢Δ͝ͱʹ্ॻ͖͞ΕΔ w ຊ൪͸ɺ೔෇

    ίϛοτϋογϡ w σϓϩΠ͝ͱʹόʔδϣϯΛ࢒ͯ͠ɺϩʔϧόοΫՄೳͳঢ়ଶʹ͓ͯ͘͠
  22. 22 σϓϩΠ w σϓϩΠޙͷϔϧενΣοΫ w σϓϩΠεΫϦϓτͰࣗಈνΣοΫ w ࣦഊͨ͠ΒϚΠάϨʔγϣϯ͠ͳ͍ w ˌσϓϩΠͰ͖͍ͯΔ͜ͱΛ֬ೝ

    gcloud app versions list | grep "${αʔϏε} *${όʔδϣϯ}.*SERVING” || return 1 # HTTPεςʔλε 200͕ฦͬͯ͘Δ͜ͱΛ֬ೝ # init()ͷΤϥʔͳͲΛݕग़Ͱ͖Δ curl --fail https://${όʔδϣϯ}-dot-${αʔϏε}-dot-${ϓϩδΣΫτ}.appspot.com/_/health” > /dev/null 2>&1
  23. 23 σϓϩΠ w ஫ҙ w ("&ͷλεΫΩϡʔ΍DSPOͷઃఆ͸̍ϓϩδΣΫτͰ͔ͭ͠؅ཧ͞Εͳ͍ w ϚΠάϨʔγϣϯ͠ͳͯ͘΋σϓϩΠ͢Δͱॻ͖׵Θͬͯ͠·͏

  24. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  25. 25 /$ͷΞʔΩςΫνϟ w Α͋͘ΔϨΠϠʔυΞʔΩςΫνϟ BQQMJDBUJPO IBOEMFS EPNBJO *OGSBTUSVDUVSF

  26. 26 ΞʔΩςΫνϟΛݕ౼͢ΔՁ஋ w ΞϓϦέʔγϣϯ։ൃʹूதͰ͖Δ w ػೳ௥ՃͷͨͼʹΞʔΩςΫνϟΛߟ͑Δͷ͸ඇޮ཰ w ౷Ұͨ͠ํ਑ͷίʔυ w ৽ϝϯόʔͷΩϟονΞοϓ͕༰қ

  27. 27 ΞʔΩςΫνϟΛݕ౼͢ΔՁ஋ͱϦεΫ w ਖ਼ղͰ͸ͳ͘ͱ΋ܾΊΔ͜ͱࣗମʹՁ஋͕͋Δ w ඞཁҎ্ʹਖ਼ղΛ௥͍ٻΊΔ͜ͱ͸ϦεΫ w ʮਖ਼͍͠%%%Λ࣮ݱ͢Δ͜ͱʯΛ໨తʹ͠ͳ͍ w ਖ਼͍͠ΞʔΩςΫνϟ͕׬੒͢Δ͜ͱ͸ͳ͍ͨΊɺແݶʹ࣌ؒΛফඅ͢ΔϦεΫ

    w ԿΛ໨తʹΞʔΩςΫνϟΛܾఆ͢Δ͔͕େ੾ w ͦͷΞʔΩςΫνϟΛબ୒ͨ͠ͳΒɺඞͣ໨తΛୡ੒͢Δ w ྫ w ໨తςετλϏϦςΟ͋͛Δ w खஈ%*Ͱ͖ΔΑ͏ʹϨΠϠʔ෼ׂΛ͢Δ w ໨తୡ੒ޙඞͣςετΛॻ͘ w ៉ྷʹͳͬͯຬ଍͢ΔͳΒػೳ։ൃΛ༏ઌ͢Δ w
  28. 28 ΞʔΩςΫνϟͷ໨తͱํ਑ w /$Ͱ͸ଟ͘ͷϏδωεϩδοΫΛ࣋ͭͨΊɺυϝΠϯΛॏ఺తʹςετ͍ͨ͠ w υϝΠϯͷςετΛಠཱ࣮ͯ͠ࢪͰ͖ΔΑ͏ʹ w ϏδωεϩδοΫ͕ಠཱ͍ͯ͠ͳ͍৔߹ͷςετ w )551ϦΫΤετͷ࡞੒ɺ%#ͷ؀ڥͷ࣮ߦɺ%#্ͷσʔλ४උ

    w ςετ؀ڥߏஙͷखؒ w ΦϯϝϞϦͰ׬݁͠ͳ͍ςετ͸஗͍ w େྔͷϞοΫΛ%* w ςετ؀ڥߏஙͷखؒ w ςετ࣮ߦ͕஗͘ɺ؀ڥߏங͕खؒͩͱςετΛॻ͔ͳ͘ͳΔ
  29. 29 /$ͷΞʔΩςΫνϟ w BQQMJDBUJPO૚ w υϝΠϯϞσϧɺ%#ɺ֎෦"1*ͳͲͱͷॲཧΛ·ͱΊ ͯɺΞϓϦέʔγϣϯͱͯ͠ͷػೳΛఏڙ͢Δɻ w %#͔Βऔಘ w

    υϝΠϯΛੜ੒ͯ͠ɺϝϞϦ্Ͱૢ࡞ w %#ʹอଘ BQQMJDBUJPO IBOEMFS EPNBJO *OGSBTUSVDUVSF func (a app)Buy(uid string, cid int64, amount, rate float64) error { u, err := a.RepoUser.Get(ctx, uid) // 1. DB͔Βऔಘ buy := domain.NewBuyOrder(u, cid, amount, rate) 2. υϝΠϯΛੜ੒ err := buy.Exec(ctx) // 2. υϝΠϯΛϝϞϦ্Ͱૢ࡞ err = a.RepoUser.Save(ctx, u) // 4 DBʹอଘ return nil }
  30. 30 /$ͷΞʔΩςΫνϟ w BQQMJDBUJPO૚ w BQQMJDBUJPOʹϏδωεϩδοΫΛॻ͔ͳ͍͜ͱ͕େ੾ w ҎԼͷίʔυ͸BQQMJDBUJPOʹϏδωεϩδοΫ͕࿙Ε͍ͯΔɻ w ߪೖॲཧΛςετ͢ΔͷʹBQQMJDBUJPO૚͕ඞਢʹͳΔɻ

    w %#ͷϞοΫૠೖ͕ඞਢʹͳΔςετͷϋʔυϧ্͕͕Δ func (a app)Buy(uid string, currency_id int64, amount, rate float64) error { u, err := a.RepoUser.Get(ctx, uid) // 1. DB͔Βऔಘ // ߪೖͨ͠௨՟Λ૿΍͢ b := u.GetBalance(currency_id) b.Add(amount) // ೔ຊԁΛݮΒ͢ yen := u.GetYenBalance() yen.Sub(amount * rate) err = a.RepoBalance.Save(ctx, b) // 4 DBʹอଘ return nil } ѱ͍ྫ
  31. 31 /$ͷΞʔΩςΫνϟ w ࣮ફυϝΠϯۦಈઃܭ1ϨΠϠҾ༻ w ΞϓϦέʔγϣϯαʔϏε͸ɺΞϓϦέʔγϣϯϨΠϠʹҐஔ෇͚ΒΕΔɻυϝΠϯαʔϏεͱ͸ҟͳ ΓɺυϝΠϯϩδοΫΛ࣋ͨͳ͍αʔϏεͩɻӬଓԽͷτϥϯβΫγϣϯ΍ɺηΩϡϦςΟΛ؅ཧ͢Δͨ Ίʹ࢖͏͜ͱ΋͋Δɻ·ͨɺଞͷγεςϜʹ௨஌ϝʔϧΛૹͬͨΓɺϢʔβ޲͚ͷϝʔϧͷϝοηʔδΛ ૊ΈཱͯͨΓ͢Δͷ΋ΞϓϦέʔγϣϯαʔϏεͷ໾ׂͩɻΞϓϦέʔγϣϯϨΠϠʹҐஔ͢ΔΞϓϦ έʔγϣϯαʔϏε͸ɺυϝΠϯϞσϧͷ௚઀ͷར༻ऀͰ͸͋Δ͕ɺࣗ෼ࣗ਎͸ϏδωεϩδοΫΛ࣋ͨ

    ͳ͍ɻ
  32. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  33. 33 ϑϨʔϜϫʔΫɺϥΠϒϥϦͷબఆ w ࠶ܝ w ඞཁҎ্ʹརศੑΛ͋͛ΔͨΊʹϑϨʔϜϫʔΫ΍ϥΠϒϥϦΛ࠾༻͠ͳ͍ w ϑϨʔϜϫʔΫΛ࠾༻͢Δ͜ͱͰɺཧղ͕༰қʹͳΔ΋ͷΛ࠾༻͢Δɻ w ˓4JNQMF

    w ίʔυͷهड़Λ୹͘͢ΔͳͲɺ࡞ۀྔΛݮΒ͢͜ͱΛ໨తͱͨ͠΋ͷ͸࠾༻͠ͳ͍ɻ w ʷ&BTZ
  34. 34 ϑϨʔϜϫʔΫɺϥΠϒϥϦͷબఆ w 8FCΞϓϦέʔγϣϯϑϨʔϜϫʔΫʹٻΊΔػೳ w ϛυϧ΢ΣΞͷૠೖखஈ w ϧʔςΟϯάͷઃఆ w DIJIUUQTHJUIVCDPNHPDIJDIJ

    w FDIP΍HJO͸ඪ४ͷOFUIUUQͱ4FSWF)UUQϝιουͷΠϯλʔϑΣʔε͕ҟͳΔ w NJEEMFXBSFΛڬΉ৔߹ʹେن໛ͳมߋ͕ඞཁʹͳΔ r := chi.NewRouter() r.Use(func(w http.ResponseWriter, r *http.Request) { // ϩά }) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(“welcome")) }) http.ListenAndServe(“:80", r)
  35. 35 ϑϨʔϜϫʔΫɺϥΠϒϥϦͷબఆ w HPSQ w (Pͷߏ଄ମͱ%#ͷςʔϒϧΛϚοϐϯά w HPSN w ςʔϒϧؒͷϦϨʔγϣϯΛղܾͯ͘͠ΕΔ

    w TFMFDU GSPNUBCMFΛॻ͘ඞཁ͕ͳ͍ type Product struct { Id int64 `db:"product_id, primarykey, autoincrement”` Price int64 `db:”unit_price"` } var p Product err := dbmap.SelectOne(&p, "select * from table WHERE id=? , id) p := &Product{1,2} err := dbmap.Insert(p)
  36. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  37. 37 "1*ͷϓϩτίϧબఆ w ϓϩτίϧͷબఆ w 3&45"1* +40/31$PS(31$  w 3&45"1*ʹଇͬͯ63-ࢦ޲Ͱ)551ϝιουΛ࢖͍෼͚Δͷ͸ઃܭʹۤ࿑͢Δɻ

    +40/31$PS(31$ʁ w ("&͸(31$ະରԠ ݱࡏ  w +40/31$ ɹ(31$͕࢖͍͍ͨ w ͳͥ(31$Λ࢖͍͍͔ͨʁ w 1SPUPDPM#V⒎FSTͷఆٛϑΝΠϧ w ΫϥΠΞϯτͱ"1*ͷιʔείʔυΛࣗಈੜ੒ w (31$Ͱ͋Δඞཁ͸ͳ͍
  38. 38 "1*ͷϓϩτίϧબఆ w ϓϩτίϧͷબఆ1SPUPDPM#V⒎FSTPO)551 w 3&45"1* +40/31$ (31$ͷ͍͍ͱ͜औΓ w 63-Ͱ࣮ߦ͢ΔϝιουΛࢦఆɻ

    w IUUQBQJFYNBQMFDPNW&YDIBOHF#VZ w )551ϝιου͸1045ͷΈ w ϦΫΤετɺϨεϙϯεɺϝιουͷܕ͸ɺ1SPUPDPM#V⒎FSTͰఆٛ w (31$ͱಉ༷ʹ(31$ͷπʔϧ܈Ͱιʔείʔυੜ੒Մೳ w 1SPUPDPM#V⒎FSTͷఆٛϑΝΠϧ͔Β(P 4XJGU 5ZQF4DSJQU +BWBͷίʔυੜ੒ w message BuyRequest{ int currency_id = 1; double amount = 2; double rate = 3; } message BuyResponse {} rpc Buy(BuyRequest) returns (BuyResponse);
  39. 39 "1*ͷϓϩτίϧબఆ1SPUPDPM#V⒎FSTPO)551ͱैདྷٕज़ͷൺֱ w 3&45"1*ͱൺֱ w ྑ͍఺31$ͳͷͰ"1*ઃܭ͕༰қ w 3&45Ͱ͸ɺ)551ϝιουɺ63-ͷݕ౼͕ඞཁ w 1VUϝιου

    W&YDIBOHF#BMBODF w 31$ͳΒɺϝιου͸1PTUݻఆɻ63-͸ίʔυ্ͷϝιουʹରԠɻ w W&YDOBIHF#VZ w +40/31$ͱൺֱ w ྑ͍఺1SPUPDPM#V⒎FSTʹΑΓɺΫϥΠΞϯτ͸"1*ͷมߋΛίϯύΠϧ࣌ʹݕग़ w ѱ͍఺ඪ४Ͱ͸ͳ͍ͷͰɺଞࣾ΍ެ։"1*ʹ͸޲͔ͳ͍ w (31$ͱൺֱ w ྑ͍఺)551ͳͷͰैདྷͷ؀ڥͰɺैདྷͷίʔυ͕ಈ͘ɻ w (31$͸ɺ(31$ͷίʔυΛॻ͘ඞཁ͕͋Δɻ w ѱ͍఺(31$ͷػೳ͕࢖͑ͳ͍ TUSFBN
  40. 40 "1*ͷϓϩτίϧબఆ1SPUPDPM#V⒎FSTPO)551Λ࢖ͬͯΈͯΑ͔ͬͨ఺ w 4UBDL%SJWFSͷϩά͕ݟ΍͍͢ w 63-͚ͩͰϝιουΛಛఆͰ͖Δɻ w 3&45)551ϝιουΛ֬ೝ͢Δඞཁ͋Γ w +40/31$63-͢΂ͯಉ͡ͳͷͰϩάͷҰཡΛݟͯ΋ύοͱݟͯΘ͔Βͳ͍

    w 1SPUPDPM#V⒎FSTPO)551 w 63-W&YDOBIHF#VZ
  41. 41 "1*ͷϓϩτίϧબఆ1SPUPDPM#V⒎FSTPO)551Λར༻ͨ͠։ൃ w 1SPUPDPM#V⒎FSTPO)551ͷ31$ w σόοά༻ʹ+40/ʹ΋ରԠͨ͠ w )551ϔομͷ$POUFOU5ZQFͱ"DDFQUΛར༻͢Δ w (31$ͷHSQDHBUFXBZͱಉ͡໾ׂ

    w
  42. 42 "1*ͷϓϩτίϧબఆ w UXJSQUXJDI੡ͷ31$GSBNFXPSL w IUUQTCMPHUXJUDIUWUXJSQBTXFFUOFXSQDGSBNFXPSLGPSHPGGFCCGG w 1SPUPDPM#V⒎FST͚ͩͰ͸ͳ͘+40/ʹ΋ରԠ w )551ͷͨΊैདྷͷ؀ڥͰ࢖͑Δ

    w .JDSPTFSWJDFTؒͷ௨৴Λ૝ఆͯ͠࡞ΒΕͨϑϨʔϜϫʔΫͳͷͰɺ(Pͷίʔυ͔͠ ੜ੒ͯ͘͠ΕͣɺΫϥΠΞϯτͱͷར༻͸Ͱ͖ͳ͍
  43. 43 "1*ͷϓϩτίϧબఆ w (31$PS)551PO1SPUPDPM#V⒎FSTͷݕ౼ w ໨త͸  w ߏ଄Խ͞ΕͨఆٛϑΝΠϧ͔ΒιʔείʔυΛੜ੒͍ͨ͠ w

    PS w TUSFBN͕࢖͍͍ͨɻͦͷଞ(31$ݻ༗ͷػೳΛ࢖͍͍ͨɻ w े෼ͳ։ൃϦιʔε͕͋Δ͔ w (31$Λ࠾༻ͯ͠ैདྷͷγεςϜ΍ίʔυ͕࢖͑ͳ͍ͱ͖ରԠՄೳ͔
  44. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  45. 45 "1*։ൃํ਑ w "1*͸มΘΔલఏͰɺΫϥΠΞϯτͷ։ൃΛࢭΊͳ͍Α͏ʹॻ͍͍ͯ͘ w ճ͘Β͍େ෯ͳมߋ͓ئ͍͍ͯ͠Δ w ࠷ॳ͔Β࢓༷Λ໢ཏ͢Δ͜ͱ͸ແཧ w ΫϥΠΞϯτνʔϜʹ͸ɺʮϦϦʔε·Ͱ͸มΘΓଓ͚Δͷڐͯ͠ʯ

    w ٯʹΫϥΠΞϯτ͔Βͷཁ๬͸ۃྗड͚Δ w ࢓༷͕໢ཏ͞ΕΔॠؒ͸ϦϦʔε௚લ w ϦϦʔε௚લ͕Ұ൪͍͍"1*Λ࡞Δ͜ͱ͕Ͱ͖Δ w ͦΕ·Ͱ௚͠ଓ͚Δ w ྑ͍΋ͷΛ࡞Γ͍ͨͱ͍͏ҙ͕ࣝڞ༗͞Ε͍ͯΔϝϯόʔͳͷͰڐ͞ΕΔ w ײँ
  46. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  47. 47 "1*ΫϥΠΞϯτͱυΩϡϝϯτ w "1*ΫϥΠΞϯτ w ։ൃதͷ"1*Λୟ͘खஈΛͲ͏͢Δ͔ʁ w DVSM w ։ൃऀ͝ͱͷಠࣗΫϥΠΞϯτ

    w ։ൃதͷΞϓϦ͔Βୟ͘
  48. 48 "1*ΫϥΠΞϯτͱυΩϡϝϯτ w 1PTUNBOΛνʔϜͰڞ༗͢Δ͜ͱͰɺαʔόαΠυɺΫϥΠΞϯταΠυͷΤϯδχΞ ͕ؾܰʹ"1*Λୟ͚Δ؀ڥΛ༻ҙ͢Δ

  49. 49 "1*ΫϥΠΞϯτͱυΩϡϝϯτ w ("&͸σϓϩΠ͢Δ͚ͩͰɺϒϥϯνઐ༻ͷ63-͕ൃߦ͞ΕΔͨΊɺΞΫηε͢Δ63- Λม਺ʹ͓ͯ͘͜͠ͱͰɺؾܰʹΞΫηεઌΛม͑ΒΕΔ w IUUQT\όʔδϣϯ^EPU\αʔϏε^EPU\ϓϩδΣΫτ^BQQTQPUDPN w ϝϯςϞʔυதͷόʔδϣϯ w

    IUUQTNBJOUFOBODFEPUBQJEPUQSPKFDU"BQQTQPUDPN ؀ڥม਺Λઃఆ ؀ڥม਺ͷ੾Γସ͑
  50. 50 "1*ΫϥΠΞϯτͱυΩϡϝϯτ w ϨεϙϯεΛม਺ʹઃఆͰ͖ΔͷͰɺ"DDFTT5PLFOͷ؅ཧ΋͓खܰ w "DDFTT5PLFOͷϨεϙϯε w ϨεϙϯεΛ؀ڥม਺ʹઃఆ w ϦΫΤετΛૹΔࡍͷɺ)551ϔομʔͰ؀ڥม਺Λࢀর

    var res = JSON.parse(responseBody); postman.setEnvironmentVariable("ACCESS_TOKEN", res.token); { "token": “accesstokennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" }
  51. 51 "1*ΫϥΠΞϯτͱυΩϡϝϯτ w 1PTUNBOΛνʔϜͰڞ༗͢Δ͜ͱͰɺαʔόαΠυɺΫϥΠΞϯταΠυͷΤϯδχΞ ͕ؾܰʹ"1*Λୟ͘͜ͱ͕Մೳ w ։ൃதͷ໰୊ൃੜ࣌ͷ੾Γ෼͚͕༰қʹͳΔ w 1PTUNBO͔Βୟ͍ͯ΋໰୊͕͋Ε͹αʔόʹ໰୊͋ΔՄೳੑ͕ߴ͍ w

    ΫϥΠΞϯτΤϯδχΞ΋αʔόαΠυΤϯδχΞʹ໰୊ڀ໌ΛཔΈ΍͘͢ͳΔ w ࣮ࡍʹಈ͘΋ͷ͕͋ΔͷͰɺυΩϡϝϯτͷ୅ΘΓʹͳΔ w 1SPUPDPM#V⒎FSTͷఆٛϑΝΠϧͱ߹Θͤͯ࢓༷ͷཧղ͕Մೳ w Θ͔Βͳ͍ͱ͜Ζ͕͋Ε͹ฉ͍ͯ΋Βͬͯղܾ w 4XBHHFS΋ඞཁͳ͍
  52. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  53. 53 DPOpH w ։ൃϓϩδΣΫτ͝ͱʹDPOpHΛઃఆ͍ͨ͠ w 42-ͷ઀ଓઌͳͲ w DPOpHͷ࣮ݱํ๏ w ZBNM΍UPNMͰಠࣗͷDPOpHϞδϡʔϧΛ࡞Δʁ

    w ("&Ͱ͸BQQZBNMͷ؀ڥม਺ʹઃఆ͢Δͷ͕ηΦϦʔ w DPOpHͷ੾Γସ͑ํ๏ w DPOpHZBNMΛ؀ڥ͝ͱʹ࡞੒ͯ͠ɺBQQZBNM͔ΒJODMVEF͢Δ w σϓϩΠ࣌ʹDPOpHZBNMΛγϯϘϦοΫϦϯΫͰ੾Γସ͑Δ env_variables: MYSQL_CONNECTION : user:pass@cloudsql(project:asia-northeast1:xxxxx)/yyy includes: - config.yaml
  54. 54 DPOpH w DPOpHͷಡΈࠐΈํ w ؀ڥม਺ΛίʔυʹಡΈࠐΉͨΊʹFOWDPOpHΛ࠾༻ɻ w DPOpHͷ஋ΛඞཁʹͳͬͨλΠϛϯάͰ؀ڥม਺͔ΒಡΈࠐΉͷͰ͸ͳ͘ɺJOJU࣌ʹ ߏ଄ମʹಡΈࠐΜͰ͓͘ w

    type Config struct { MysqlConnection string `required:"true" split_words:"true"` var C Config func Setup() { if err := envconfig.Process(“prefix", &C); err != nil { panic(err) } }
  55. 55 DPOpH w DPOpHͷಡΈࠐΈํ w ·ͨಡΈࠐΜͩ஋Λ֤ϨΠϠʔ͔Β௚઀ࢀর͸ͤͣɺJOJU࣌ʹ֤ϨΠϠʔͷߏ଄ମʹ ηοτ͓ͯ͘͠ɻ w ςετ࣌ʹDPOpHϞδϡʔϧ͕ඞਢʹͳΔ͜ͱΛආ͚Δ w

    ςελϏϦςΟͷ޲্
  56. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  57. 57 ηΩϡϦςΟ w $MPVE,.4 w ݸਓ৘ใɺ֎෦ͷ"1*ΩʔͳͲྲྀग़ͯ͠͸͍͚ͳ͍΋ͷ͸$MPVE,.4Λ࢖ͬͯ҉߸Խ্ͨ͠Ͱ อଘ͢Δɻ w ҉߸Խ͢Δ͏͑Ͱͷൿີ伴Λಠࣗʹ༻ҙͯ͠؅ཧ͢Δඞཁ͕ͳ͍ɻ w

    ௚઀EBUBTUPSFͷσʔλ͕ྲྀग़ͯ͠΋҉߸Խ͞Ε͍ͯΔͨΊ໰୊͸ى͖ͳ͍ɻ w 伴ͷϩʔςʔτΛఆظతʹ͢Δ͜ͱͰɺྲྀग़ͨ͠ࡍͷϦεΫΛ௿ݮɻ w 伴ͷϩʔςʔτͷ࠶҉߸ԽͳͲ΋Մೳɻ w ΦʔφʔݖݶΛ࣋ͬͨ(PPHMFΞΧ΢ϯτͱύεϫʔυ͕ྲྀग़ͨ͠৔߹ͷΈ໰୊ͱͳΔɻ w $MPVE,.4ࣗମͷೝূ͸("&ͷαʔϏεΞΧ΢ϯτͰߦ͏ɻ w ݖݶΛ࣋ͬͨαʔϏεΞΧ΢ϯτͷΩʔΛੜ੒͍ͯ͠ͳ͚Ε͹ɺ֎෦͔Β$MPVE,.4Λୟ ͘͜ͱ΋Ͱ͖ͳ͍ɻ w ΋͠αʔϏεଆͷϢʔβͷΞΧ΢ϯτͱύεϫʔυ͕࿙Εͨ৔߹ʹ΋ɺର৅Ϣʔβͷݸਓ৘ใ ͔͠ྲྀग़͸͠ͳ͍ɻ w ৄࡉ͸ެࣜυΩϡϝϯτͱHDQVHOPVIBVΛࢀর w IUUQTHJUIVCDPNHDQVHOPVIBVUSFFNBTUFSDMPVELNTQPFNJOUSPEVDUJPO w
  58. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  59. 59 ։ൃ؀ڥ w ৽نͷ։ൃऀ͕ೖͬͨࡍͷ։ൃ؀ڥߏங w (Pͷ։ൃ؀ڥ w HPJNQPSUT w EFQ

    w ΤσΟλɺ*%&͸ࣗ༝ w 7JN w (P-BOE w HPMBOHUPLZPˌͰ(P։ൃ؀ڥ(PHMBOEͷϥΠϒσϞΛݟ͖ͯͨ w IUUQUFDINFSDBSJDPNFOUSZ w
  60. 60 ։ൃ؀ڥ w ৽نͷ։ൃऀ͕ೖͬͨࡍͷ("&։ൃ؀ڥߏங w ίϚϯυϥΠϯͰ͢΂ͯΛ࣮ݱ w ($1ͷίϯιʔϧΛ৮Βͳ͍ w ίϚϯυͳΒखॱ͕࢒ΓɺεΫϦϓτͱͯ͠ߏ੒؅ཧ͕Մೳ

    w *OGSBTUSVDUVSFBTDPEFɺίϚϯυΛௐ΂Ε͹ԿΛ΍͍ͬͯΔ͔Θ͔Δ w 8JLJͳͲʹखॱΛ·ͱΊΔඞཁ΋ͳ͍ w ($1ίϯιʔϧ͸೔ʑߋ৽͞ΕΔͨΊυΩϡϝϯτͷ௥ै͕೉͍͠ w ؀ڥߏங࣌ʹ౓͚ͩॱ൪ʹίϚϯυΛୟ͚ͩ͘ͳͷͰTIFMMTDSJQUͰ࣮ݱ w 04ͷঢ়ଶ؅ཧ͢ΔΘ͚Ͱ͸ͳ͍ͨΊEPDLFS BOTJCMF DIFG͸ར༻͠ͳ͍
  61. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  62. 62 $*؀ڥ w $*πʔϧʹٻΊΔػೳ w %PDLFSJNBHF͕࢖͑Δ w Ωϟογϡػೳ͕͋Δ w ߴ଎

    w ෳࡶͳػೳΛ$*πʔϧʹٻΊͳ͍+FOLJOT͓͡͞Μ͕ඞཁʹͳΔ͜ͱΛආ͚Δ
  63. 63 $*؀ڥ w $JSDMF$* w USBWJT͔ΒҠͬͨΒഒʹ w $JSDMF$*ΑΓ଎͍4BB4͕ͰͨΒҠߦ͍ͯ͘͠ w ("&(P༻ͷ$*ΠϝʔδNFSDBSJEPDLFSBQQFOHJOFHP

    w HPBQQUFTU΍HDMPVEʹΑΔσϓϩΠ͕Մೳ w ෆ଍͍ͯ͠Δπʔϧ͸NFSDBSJBQQFOHJOFHPΛϕʔεΠϝʔδͱͯ͠ಠࣗΠϝʔδΛ࡞੒ w $JSDMF$*্ͰπʔϧͷΠϯετʔϧ͸͠ͳ͍ w ςετ͕஗͘ͳΔ w ஗͘ͳΒͳ͍ͨΊʹΩϟογϡ͢ΔॲཧΛॻ͘ͱDJSDMFDJDPOpHZBNM͕େ͖͘ͳΔ w $*πʔϧ΁ͷґଘ͕େ͖͘ͳΔ
  64. 64 $*؀ڥ w ద੾ʹ੹຿Λ෼ׂ w $JSDMF$* DJSDMFDJDPOpHZBNM  w %PDLFSJNBHF

    w .BLFpMF w TIFMMTDSJQU
  65. 65 $*؀ڥ w ద੾ʹ੹຿Λ෼ׂ w $JSDMF$* DJSDMFDJDPOpHZBNM  w ࣮ߦ؀ڥͷࢦఆ

    w ϦϙδτϦͷDMPOF w $*΁ͷࢦࣔ w $JFDMF$*͸ϩʔΧϧͰ࣮ߦՄೳ w DJFDMFDJCVJME w $*؀ڥͷσόοάʹศར version: 2 jobs: build: working_directory: /go/src/github.com/org/proj docker: - image: sonatard/appengine-go steps: - checkout - run: command: make ci
  66. 66 $*؀ڥ w ద੾ʹ੹຿Λ෼ׂ w %PDLFSJNBHF w ࣮ߦ؀ڥͷߏஙʹಛԽ͢Δ w Πϝʔδʹ͸ϓϩδΣΫτͷݻ༗৘ใ͸ࡌͤͳ͍

    w 伴 w $JSDMF$*ͷ؀ڥม਺ʹઃఆ w ιʔείʔυ w (JUIVCϦϙδτϦʹ഑ஔ w ެ։ՄೳͳΠϝʔδʹ͢Δ w ೝূɺηΩϡϦςΟͷۤ࿑͕ͳ͘ͳΔ w FROM mercari/appengine-go:1.8-slim ←ϕʔεΠϝʔδʹ͢Δ ARG PROTOC_VERSION=3.4.0 RUN curl -fo protoc.zip -sSL “https://github.com/protobuf/releases/protoc-${PROTOC_VERSION}-linux-x86_64.zip" // ུ
  67. 67 $*؀ڥ w ద੾ʹ੹຿Λ෼ׂ w .BLFpMF w ਓؒͱTIFMMTDSJQUΛܨ͙ΠϯλʔϑΣʔε w NBLFpMFʹॲཧ͸ॻ͔ͣɺTIFMMTDSJQUͷίϚϯυΛ࣮ߦ͢Δ͚ͩ

    w $*Ͱ࣮ߦ͢ΔίϚϯυͱ։ൃͰ࣮ߦ͢ΔίϚϯυ͸ՄೳͳݶΓಉ౳ʹ͢Δ w dep: dep ensure -vendor-only -v test: gen test.sh $(GOLIST) ci: ci.sh deploy_qa: gen deploy.sh qa $(ALL_SERVICES) deploy_prod: gen deploy.sh qa $(ALL_SERVICES)
  68. 68 $*؀ڥ w ద੾ʹ੹຿Λ෼ׂ w TIFMMTDSJQU w ۩ମతͳॲཧΛهड़͢Δ GOLIST=$(goapp list

    ./... | grep -v vendor) test.sh ${GOLIST} branch=$(git rev-parse --abbrev-ref @) if [ "x${branch}" = "xmaster" ] ; then deploy_target="qa" else # ։ൃϒϥϯν͸σϓϩΠ͠ͳ͍ return 0 fi all_services="api batch pre default" deploy.sh "${deploy_target}" “${all_services}"
  69. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  70. 70 ςετ w 5BCMF%SJWFO5FTU w ςετέʔεΛ໢ཏ͢Δ͜ͱ͕໌ࣔ͞ΕΔ w UFTUJGZͳͲͷςετϑϨʔϜϫʔΫ͸࢖Θͳ͍ w ̍ϝιουʹଟͯ͘ճ͘Β͍ͷ஋ൺֱͳͷͰɺૉ௚ʹΤϥʔग़ྗΛࣗ෼Ͱॻ͘

    w ߏ଄ମͷൺֱͷͨΊʹHPDNQΛར༻ w IUUQTHJUIVCDPNHPPHMFHPDNQ w ςετ༻ͷ֎෦πʔϧΛۃྗ࢖Θͳ͍ w πʔϧΛֶͿίετ w ςετΛॻ͘ϋʔυϧͷ૿Ճ
  71. 71 ςετ w ϞοΫͷૠೖ͸ςετ͕ෳࡶʹͳΔͷͰۃྗճආ͍ͨ͠ w ςετͰϞοΫΛૠೖ͕ඞཁʹͳΒͳ͍Α͏ɺઃܭͯ͠ίʔυΛॻ͘ w υϝΠϯ͸ɺଞͷϨΠϠʔґଘΛͳ͘͢ w ΞϓϦέʔγϣϯ΁ͷϏδωεϩδοΫͷ࿙ӮΛආ͚Δ

    w 4VC5FTUΛ࢖͏ w ͲͷςετέʔεͰམ͔ͪͨΒΘ͔Γ΍͘͢͢ΔͨΊ w IUUQTXXXTMJEFTIBSFOFUUBLVZBVFEBHPGSJEBZ w
  72. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  73. 73 ϩάղੳ w ($1ͱ͍͑͹#JH2VFSZ w ඞཁͦ͏ͳϩά͸4UBDL%SJWFSʹ͸͍ͯ#JH2VFSZʹΠϯϙʔτ͓ͯ͘͠ w "1*ͷΞΫηεϩάͳͲ w ো֐࣌ʹͱͯ΋໾ʹཱͭ

    w
  74. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  75. 75 EBUBTUPSFͷόοΫΞοϓ w EBUBTUPSF($4 w ($4#JH2VFSZ w IUUQTHJUIVCDPNGBWDMJQETCR

  76. • ٕ ज़ બ ఆ ͷ ج ຊ ํ ਑

    • ϓ ϩ δ Σ Ϋ τ ߏ ੒ • α ʔ Ϗ ε ߏ ੒ • σ ϓ ϩ Π • Ξ ʔ Ω ς Ϋ ν ϟ • ϑ Ϩ ʔ Ϝ ϫ ʔ Ϋ ɺ ϥ Π ϒ ϥ Ϧ • A P I ϓ ϩ τ ί ϧ • A P I ։ ൃ ํ ਑ • A P I Ϋ ϥ Π Ξ ϯ τ ͱ υ Ω ϡ ϝ ϯ τ • c o n f i g • η Ω ϡ Ϧ ς Ο • ։ ൃ ؀ ڥ • C I ؀ ڥ • ς ε τ • ϩ ά ղ ੳ • d a t a s t o r e ͷ ό ο Ϋ Ξ ο ϓ
  77. 77 ·ͱΊ w /FYU$VSSFODZͷߏ੒ w (PPHMF"QQ&OHJOF(P EBUBTUPSF $MPVE42- w ϑϨʔϜϫʔΫHPDIJ

    ϧʔςΟϯάͱϛυϧ΢ΣΞ  w ߏ଄ମͱ%#ςʔϒϧͷόΠϯυHPSQ w ϨΠϠʔυΞʔΩςΫνϟ )BOEMFS "QQMJDBUJPO %PNBJO *OGSBTUSVDUVSF  w (31$ޓ׵ͷಠࣗ)551ϕʔεͷ31$ w DPOpHFOWDPOpH w $JSDMF$* NFSDBSJEPDLFSBQQFOHJOFHP QSPUPDΛՃ͑ͨΠϝʔδ  w 5FTUඪ४ͷUFTUJOHύοέʔδ HPDNQ w σόοά༻"1*ΫϥΠΞϯτ1PTUNBO w ػີ৘ใͷ؅ཧ$MPVE,.4 w ղੳ#JH2VFSZ w 4UBDL%SJWFS͔ΒΠϯϙʔτ w EBUBTUPSF͔ΒΠϯϙʔτ GBWDMJQETCR
  78. 78 ͋Γ͕ͱ͏͍͟͝·ͨ͠