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

Go Cloud まとめ

5248c7e88d8a46c1754c6762fcab3c3a?s=47 jewel12
October 23, 2018
33

Go Cloud まとめ

5248c7e88d8a46c1754c6762fcab3c3a?s=128

jewel12

October 23, 2018
Tweet

Transcript

  1. (P$MPVE·ͱΊ 0LJOBXBHP !KFXFM@Y

  2. !KFXFM@Y w ΞυςΫձࣾͷ͓ख఻͍ w ԭೄɾٓ໺࿷ΤϯδχΞษڧձ w ςʔϚΛ໰ΘͣΤϯδχΞಉ࢜ϫΠϫΠ͢ΔΏΔ͍ձ w ʹ͋ΔͷͰൃදɾ-5ͱ΋ʹ͓଴ͪͯ͠·͢ʂ w

    ࠓ೔͸(P$MPVEʹ͍ͭͯௐ΂ͯΈ·ͨ͠
  3. (P$MPVE w 8SJUFPODF SVOPOBOZDMPVE w $MPVE1MBUGPSNʹґଘ͠ͳ͍ɺϙʔλϒϧͳΞϓϦέʔγϣϯ Λॻͨ͘ΊͷϓϩδΣΫτ w ґଘ෦෼͸গͳͯ͘͠ϚϧνΫϥ΢υΛ࣮ݱ͍ͨ͠ w

    (P͸Ϋϥ΢υ؀ڥͰ࢖ΘΕΔύλʔϯ͕ଟ͍ w $MPVE*OGSBTUSVDUVSF5PPMT ,T *TUJP %PDLFS  w ༷ʑͳαʔϏε͕Ϋϥ΢υ؀ڥͰ(PΛ࢖͍ͬͯΔ -ZGU $BQJUBM 0OF /FUqJY 'SPN1PSUBCMF$MPVE1SPHSBNNJOHXJUI(P$MPVE
  4. (P$MPVE w ·ͩBMQIB൛ w εϥΠυͷ಺༰΋มΘΔՄೳੑ͕͋Γ·͢

  5. ϙʔλϒϧ͞ͷ࣮ݱํ๏  w $MPVE1MBUGPSNʹґଘͨ͠ίʔυͷ࡟ݮ w ґଘͨ͠ίʔυͱ͸ w $MPVE1MBUGPSN4%,ͷΠϯλʔϑΣʔεͷҧ͍ w ࣮ݱํ๏ͷίΞ͸ͭ

    w ڞ௨"1* w 4%,ηοτΞοϓίʔυͷ*OKFDUJPO
  6. ڞ௨"1*  w ֤$MPVE1MBUGPSNΛ࢖͏ͨΊͷॳظԽҎ֎͸ಉ͡ॻ͖ ํͰΫϥ΢υαʔϏεΛར༻͍ͨ͠ w ಉ͡ॻ͖ํͰΫϥ΢υετϨʔδ΍3%#΁ͷಡΈॻ ͖͕Ͱ͖ΔΑ͏ʹ w ྫ͑͹4

    ($4όέπ΁ͷಡΈॻ͖͸JP8SJUFS  JP3FBEFSΠϯλʔϑΣʔεΛ࣮૷ͨ͠8SJUFS  3FBEFSΛ࢖͏
  7. όέπಡΈॻ͖  w νϡʔτϦΞϧίʔυΛಡ΋͏ … b, err := setupBucket(context.Background(), *cloud,

    *bucketName) w, err := b.NewWriter(ctx, file, nil) _, err = w.Write(data) w (PPHMF$MPVE42-΍"NB[PO3%4Λ࢖͏৔߹΋ EBUBCBTFTRMͷΠϯλʔϑΣʔεΛ࣮૷ͨ͠υϥΠό Λ࢖༻͢Δ͜ͱʹͳΔ
  8. ରԠ͍ͯ͠Δڞ௨"1* w #JOBSZ4UPSBHF΍.Z42-ͷଞʹ w 3FRVFTU-PHHJOH w /4$"$PNNPO-PH'PSNBU΍4UBDLESJWFSͷϑΥʔϚοτͰ )551ϦΫΤετϩάΛు͍ͯ͘ΕΔ)551)BOEMFSΛఏڙ w )FBMUI$IFDL༻)BOEMFS΋ಉ༷ʹఏڙ

    w 5SBDJOH w 0QFO$FOTVTͰऩूͨ͠τϨʔε༻σʔλΛ4UBDLESJWFS΍ "NB[PO93BZʹૹΔ
  9. ͜Ε͔ΒରԠ͢Δͷ͸ʁ w ͋Μ·Γ௥͍͑ͯͳ͍ w ࠓͷͱ͜Ζʢ࣌఺ʣ͸($1ͱ"84ʹ ͍࣮ͭͯ૷͞Ε͍ͯΔ w 1VMMSFRVFTUTʹ͸(PPHMF$MPVE,.4ͷ࣮૷͕͋Δ

  10. 4%,ηοτΞοϓίʔυ w ֤4%,ηοτΞοϓʹ͸ύλʔϯ͕͋Δͱ͞ΕΔ ʢ1PSUBCMF$MPVE1SPHSBNNJOHXJUI(P$MPVEΑΓʣ  w ͜ͷύλʔϯ෦෼ΛखͰશ෦ॻ͔ͳ͍Ͱɺඞཁ࠷௿ݶ ෼͚ͩίʔυهड़͢Δͱ$MPVE1MBUPGPSNґଘίʔ υ͕ݮΔ w

    HPDMPVETBNQMFTHVFTUCPPLXJSF@HFOHPΛݟͯ ͘Ε w ࠷ऴతͳηοτΞοϓίʔυʹͳΔ
  11. HPDMPVETBNQMFT HVFTUCPPLXJSF@HFOHP w XJSF@HFOHP͸8JSFͱ͍͏πʔϧͰࣗಈੜ੒͞Εͨ ίʔυ w ࣗಈੜ੒ͷͨΊͷఆٛ͸JOKFDU@YYYHP "84͸͜ ͜ʣ

  12. HPDMPVETBNQMFT HVFTUCPPLXJSF@HFOHP func setupAWS(ctx context.Context, flags *cliFlags) (*application, func(), error)

    { wire.Build( awscloud.AWS, applicationSet, awsBucket, awsMOTDVar, awsSQLParams, ) return nil, nil, nil } w 3%4઀ଓઃఆͳͲΛऴΘΒͤͯBQQMJDBUJPOTUSVDUͷ ॳظԽΛ͢Δίʔυ͕୹͘ॻ͚ͨ
  13. 8JSF w ηοτΞοϓίʔυͷੜ੒Λ͢ΔͨΊͷ%* %FQFOEFODZ*OKFDUJPO ίϯςφͰɺHPDMPVEͷί Ξπʔϧͱͯ͠ͷҐஔ෇͚͕ͩ୯ମͰίϯύΠϧλΠϜ %*ίϯςφͱͯ͠࢖༻Ͱ͖Δ w 1SPWJEFSͱ͍͏ґଘੑΛ஫ೖ͍ͨ͠ίϯϙʔωϯτ ͷηοτʹରͯ͠ґଘղܾΛߦ͍ɺίʔυੜ੒Λ͢Δ

    w ֤छηοτΞοϓίʔυͷύλʔϯ͸HPDMPVEBXT BXTDMPVEʹίϯϙʔωϯτηοτͱͯ͠ஔ͍ͯ͋Δ ͷͰ͜ΕΛ࢖͏ͱॻ͘ηοτΞοϓίʔυ͕୹͘ͳΔ
  14. 8JSF w ΋͏ͪΐ͍ৄ͘͠͸!CVEPVHVNJ͞ΜͷHPDMPVE ͱ8JSFΛར༻ͨ͠%*Λࢀর w ೔લʹࣅͨࢿྉ͕ग़͍ͯΔͷʹࠓ೔ؾ෇͍ͨʜʜ w 1SPWJEFSͱ*OKFDUPS w 1SPWJEFSґଘੑΛఆٛͨ͠ίϯϙʔωϯτ

    w *OKFDUPS1SPWJEFSΛґଘॱ൪Ͱฒ΂ͯίʔυੜ੒ w 1SPWJEFS΋*OKFDUPS΋GVODUJPOͰදݱ͞Εɺγάωνϟ ͰґଘੑͷఆٛͱղܾΛ͍ͯͯ͠໘ന͍
  15. ·ͱΊ w (P$MPVEͰ$MPVE1MBUGPSNʹґଘ͠ͳ͍ɺϙʔλϏ ϦςΟΛ࣋ͬͨίʔυΛॻ͖΍͘͢ͳͬͨʢ͸͕ͣͩ· ͩBMQIBʣ w 8JSF͸໘ന͍ w (Pʹ͓͚Δ"45ղੳͷ࣮༻ྫͷͻͱͭͱͯ͠ࢀߟ ʹͳΔ