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

GoとNature ~ Nature Remoの裏側 / Nature Bath vol6

Songmu
December 02, 2020

GoとNature ~ Nature Remoの裏側 / Nature Bath vol6

Songmu

December 02, 2020
Tweet

More Decks by Songmu

Other Decks in Technology

Transcript

  1. 2 Me • দ໦ խ޾ (id:Songmu) • Nature גࣜձࣾ औక໾CTO

    • https://songmu.jp/riji • https://github.com/Songmu • ޷͖ͳݴޠ͸GoͱPerlͱதࠃޠ • 3 Times ISUCON Winner • ஶॻʹʮΈΜͳͷGoݴޠʯ౳ • झຯ͸OSS׆ಈͰ͢
  2. 3 Created Miscellaneous Go Tools • maltmill • πʔϧΛ؆୯ʹhomebrewͰ഑෍͢ΔͨΊͷπʔϧ •

    horenso • όονδϣϒͷͨΊͷϥούʔ • peep • ϓϩηεͷऴྃ௨஌Λͯ͘͠ΕΔ܅ • gocredits • Goͷπʔϧ഑෍࣌ʹґଘϥΠϒϥϦͷLICENSEΛಉࠝ • etc. • ref. ʮGoͰπʔϧΛྔ࢈͢Δ๻ͷํ๏ʯ • https://junkyard.song.mu/slides/gocon2019-fukuoka/#0
  3. 4 Maintaining major Go tools • ghq (github.com/x-motemen/ghq) • ιʔείʔυϦϙδτϦ؅ཧπʔϧ

    • ghq handbook • https://leanpub.com/ghq-handbook • ghr (github.com/tcnksm/ghr) • GitHub΁ͷόΠφϦϦϦʔε༻πʔϧ
  4. 5 Recent Works • Let's Encryptͷϧʔτূ໌ॻมߋ໰୊ • Android7.1ҎલͰLet's Encryptূ໌ॻͷαΠτ͕ݟΒ Εͳ͘ͳΔ

    • https://songmu.jp/riji/entry/2020-09-22-letsencrypt.html • Let's Encryptͷূ໌ॻ੾ସपΓͦͷޙ • https://songmu.jp/riji/entry/2020-09-22-letsencrypt.html
  5. Remarkable Points • ૉ๿ͳGo੡ͷWebΞϓϦέʔγϣϯ • Redis Pub/SubΛ༻͍ͨɺAPI - Streamؒͷ΍ΓͱΓ •

    Nature Remo͸ALBΛܦ༝ͯ͠streamαʔόʔʹ WebSocket઀ଓ͍ͯ͠Δ • AlexaͷΧελϜεΩϧ͸AWS Lambdaܦ༝Λ࢖࣮ͬͯߦ ͞ΕΔ
  6. Simple Web Applications with Go • ී௨ͷWebΞϓϦέʔγϣϯ • ΋ͱ΋ͱherokuͰϗετ໊͍ͯͨ͠࢒΋ •

    ϑϨʔϜϫʔΫ • github.com/nbio/hitch • Gorilla web toolkitΛ෦෼తʹར༻ • MySQL/Redis • gorp/redigo • guregu/dynamo
  7. Utilize Redis Pub/Sub • Redis Pub/SubΛ׆༻͍ͯ͠Δ • API͔Β͸RedisʹPublish • Stream͸RedisΛSubscribe

    • ૬ޓ௨৴͠ͳ͍ૄ݁߹Λ࣮ݱ͍ͯ͠Δ • Streamଆ͸͋͘·ͰWebSocketͱRedis͔ΒͷSubscribeͰ ड͚෇໋͚ͨྩͷ࣮ߦ͔͓͜͠ͳΘͣঢ়ଶΛ࣋ͨͳ͍
  8. ೔ʑͷۀ຿ • GitHub্Ͱ։ൃ • CircleCI্ͰCI/CD • developϒϥϯν͔ΒfeatureϒϥϯνΛ੾Δ • ϨϏϡʔͯ͠Ϛʔδ •

    renovateʹΑΔϥΠϒϥϦࣗಈΞοϓσʔτ • developϒϥϯν͔Βmasterϒϥϯν΁ͷpull request • git-pr-releaseʹΑͬͯࣗಈ࡞੒ • Ϛʔδ͞ΕͨΒࣗಈͰຊ൪deploy
  9. CI/CD Pipelines git-pr-release git push go test go build docker

    build docker push ecspresso deploy 1 2 3 4
  10. খωλ: όονྨͷಈ͔͠ํ • APIͱworkerͱόον͸ಉ͡GoόΠφϦɺಉ͡ίϯςφ • Task Definition͸ҧ͏΋ͷ΋ • αϒίϚϯυͰॲཧΛ෼͚Δ •

    nature server: APIαʔόʔͷىಈ • nature squadrons: ϫʔΧʔͷىಈ • nature batch hoge ... : όονྨͷىಈ
  11. 34 ςετߴ଎ԽͷͨΊͷgotesplit • github.com/Songmu/gotesplit • CI؀ڥͰͷςετฒྻ࣮ߦΛ؆୯ʹ࣮ݱ • CircleCI / GitHub

    Actions • ࣾ಺ͷςετ͕࣌ؒ15෼->5෼ʹ • ͔ͳΓศརͳͷͰͥͻ͝ར༻͍ͩ͘͞
  12. 54 OSS΁ͷpull request • ʮڠௐʯͰ͖Δ͔Λॏࢹ • pull requestΛૹͬͯΈͯ୳ΓΛೖΕΔ • ࢥ૝͕Ϛον͍ͯͦ͠͏͔

    • ϝϯςφϯε͕ΞΫςΟϒ͔ • ϝϯςφϯε͕ࢭ·ͬͯΔͱࢥ͍͖΍͙͢ʹ ରԠͯ͘͠ΕΔ͜ͱ΋ • 1೥ܦ͔ͬͯΒϚʔδ͞ΕΔ͜ͱ΋