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

Go製MVCアプリケーションのアーキテクチャを変更する

inari111
January 29, 2020

 Go製MVCアプリケーションのアーキテクチャを変更する

inari111

January 29, 2020
Tweet

Other Decks in Programming

Transcript

  1. • ܊ ୓࠸ • Twitter: @inari111 • GitHub: @inari111 •

    Go / Layered Architecture / Protocol buffers • 2019.04~ hey (Coiney) • πέ෷͍ ࣗݾ঺հ
  2. ϑϨʔϜϫʔΫ͸revelΛ࢖༻ app ᵓᴷᴷ client ᵓᴷᴷ controllers ᵓᴷᴷ library ᵓᴷᴷ models

    ᵓᴷᴷ routes ᵓᴷᴷ services ᵋᴷᴷ views ࠓͷΞʔΩςΫνϟ $POUSPMMFS 4FSWJDF .PEFM .PEFMͷؔ਺ݺͼग़͠ $MJFOU 4.4ૹ৴ ֎෦"1* ϏδωεϩδοΫ ӬଓԽॲཧ
  3. •ModelԼ͕ؔ਺ʹͳ͍ͬͯΔՕॴ͕ଟ͍ • ؔ਺໊͕௕͘ͳͬͯ͠·͏ • GetConsumerByPhoneNumber, UpdateSettlementToXXX… • ؔ਺ͳͷͰͲͷService͔ΒͰ΋ݺͼग़ͤͯ͠·͏ • mockԽ͕εϚʔτʹͰ͖ͳ͍

    •Modelͷίʔυ͕ଟ͘ͳ͖ͬͯͨ •Model͕domain΍infraͷ໾ׂΛ୲͍ͬͯΔ •ӬଓԽͷॲཧͱυϝΠϯϩδοΫ͕෼཭Ͱ͖͍ͯͳ͍ ໰୊఺
  4. ৽͍͠ ΞʔΩςΫνϟ(Ծ) $POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ $MJFOU 4.4ૹ৴ ֎෦"1*

    ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮૷ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮૷ ࢀরܥϞσϧ υϝΠϯϞσϧ
  5. • υϝΠϯϞσϧ • ϏδωεϩδοΫ • Repositoryͷinterface Domain $POUSPMMFS %PNBJO 4FSWJDF

    .PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮૷ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮૷ ࢀরܥϞσϧ υϝΠϯϞσϧ
  6. • DBϞσϧ • Repositoryͷ࣮૷ • υϝΠϯϞσϧ 㲗 DBϞσϧ • Query

    Serviceͷ࣮૷ Model $POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮૷ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮૷ ࢀরܥϞσϧ υϝΠϯϞσϧ
  7. • ෳ਺ू໿ʹ·͕ͨΔσʔλΛऔಘ ͢ΔͨΊʹಋೖ • ServiceʹࢀরܥϞσϧɺ interfaceΛఆٛ • interfaceͷ࣮૷͸Modelʹஔ͘ Query Service

    $POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮૷ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮૷ ࢀরܥϞσϧ υϝΠϯϞσϧ