Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Go製MVCアプリケーションのアーキテクチャを変更する
Search
inari111
January 29, 2020
Programming
0
2.5k
Go製MVCアプリケーションのアーキテクチャを変更する
inari111
January 29, 2020
Tweet
Share
Other Decks in Programming
See All in Programming
.NET Conf 2024の振り返り
tomokusaba
0
170
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
6
2.2k
競技プログラミングで 基礎体力を身につけよう / You can get basic skills through competitive programming
mdstoy
0
120
Leverage LLMs in Java with LangChain4j and Quarkus
hollycummins
0
100
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
11
2.2k
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
7
2.6k
Vapor Revolution
kazupon
2
2.3k
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
3.6k
Java 23の概要とJava Web Frameworkの現状 / Java 23 and Java web framework
kishida
2
360
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
130
Gestaltung digitaler Lösungen – Produktions- oder Designprozess?
techstories
0
110
Remix on Hono on Cloudflare Workers
yusukebe
1
360
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
A Tale of Four Properties
chriscoyier
156
23k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Side Projects
sachag
452
42k
Rails Girls Zürich Keynote
gr2m
94
13k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
RailsConf 2023
tenderlove
29
910
Producing Creativity
orderedlist
PRO
341
39k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
GoMVCΞϓϦέʔγϣϯͷ ΞʔΩςΫνϟΛมߋ͢Δ 2020.01.29 howtv.go - @inari111
• ܊ ࠸ • Twitter: @inari111 • GitHub: @inari111 •
Go / Layered Architecture / Protocol buffers • 2019.04~ hey (Coiney) • πέ͍ ࣗݾհ
None
ి൪߸Λೖྗ SMSૹ৴ λοϓͯ͠ಉҙͰ πέ͍ྃ 2ϲ݄ҎʹίϯϏχͰࢧ͍
• ࠓͷπέ͍ͷΞʔΩςΫνϟ • ࠓͷΞʔΩςΫνϟͷ • ৽͍͠ΞʔΩςΫνϟ(Ծ) ࠓ͢͜ͱ
ϑϨʔϜϫʔΫrevelΛ༻ app ᵓᴷᴷ client ᵓᴷᴷ controllers ᵓᴷᴷ library ᵓᴷᴷ models
ᵓᴷᴷ routes ᵓᴷᴷ services ᵋᴷᴷ views ࠓͷΞʔΩςΫνϟ $POUSPMMFS 4FSWJDF .PEFM .PEFMͷؔݺͼग़͠ $MJFOU 4.4ૹ৴ ֎෦"1* ϏδωεϩδοΫ ӬଓԽॲཧ
•ModelԼ͕ؔʹͳ͍ͬͯΔՕॴ͕ଟ͍ • ໊͕ؔ͘ͳͬͯ͠·͏ • GetConsumerByPhoneNumber, UpdateSettlementToXXX… • ؔͳͷͰͲͷService͔ΒͰݺͼग़ͤͯ͠·͏ • mockԽ͕εϚʔτʹͰ͖ͳ͍
•Modelͷίʔυ͕ଟ͘ͳ͖ͬͯͨ •Model͕domaininfraͷׂΛ୲͍ͬͯΔ •ӬଓԽͷॲཧͱυϝΠϯϩδοΫ͕Ͱ͖͍ͯͳ͍
•ίʔυྔ͕૿͖͑ͯͯɺϝϯςͮ͠Β͍Օॴ͕ग़͖ͯͨ •υϝΠϯϩδοΫͱӬଓԽॲཧΛ͚Δ͜ͱͰؔ৺ࣄͷ Λߦ͍͍ͨ ͳͥΞʔΩςΫνϟΛมߋ͍ͨ͠ͷ͔
৽͍͠ ΞʔΩςΫνϟ(Ծ) $POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ $MJFOU 4.4ૹ৴ ֎෦"1*
ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮ ࢀরܥϞσϧ υϝΠϯϞσϧ
• υϝΠϯϞσϧ • ϏδωεϩδοΫ • Repositoryͷinterface Domain $POUSPMMFS %PNBJO 4FSWJDF
.PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮ ࢀরܥϞσϧ υϝΠϯϞσϧ
domain/consumer/repository.go
services/consumer.go
• DBϞσϧ • Repositoryͷ࣮ • υϝΠϯϞσϧ 㲗 DBϞσϧ • Query
Serviceͷ࣮ Model $POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮ ࢀরܥϞσϧ υϝΠϯϞσϧ
• ෳूʹ·͕ͨΔσʔλΛऔಘ ͢ΔͨΊʹಋೖ • ServiceʹࢀরܥϞσϧɺ interfaceΛఆٛ • interfaceͷ࣮Modelʹஔ͘ Query Service
$POUSPMMFS %PNBJO 4FSWJDF .PEFM 3FQPTJUPSZݺͼग़͠ ϏδωεϩδοΫ 3FQPTJUPSZ*OUFSGBDF %#Ϟσϧ 3FQPTJUPSZ࣮ 2VFSZ4FSWJDF*OUFSGBDF 2VFSZ4FSWJDF࣮ ࢀরܥϞσϧ υϝΠϯϞσϧ
• ৽نػೳՃΛࢭΊͣʹ͍͍ײ͡ʹϦϑΝΫλΛਐΊ͍ͯ͘ʹ • ෳRepositoryʹ·͕ͨΔτϥϯβΫγϣϯ • ServiceͰτϥϯβΫγϣϯுΔ͔͠ͳ͍…ʁ • ίʔυྔ͕૿͑ͯ͘ΔͱMVCͩͱͭΒ͍…ͱࢥ͏ Έ
• RepositoryͷಋೖʹΑΓӬଓԽॲཧͱυϝΠϯϩδοΫ ͷΛߦ͏͜ͱʹͨ͠ • Query ServiceΛ࡞ͯ͠ෳूʹ·͕ͨΔσʔλΛ औಘ͢Δ͜ͱʹͨ͠ • DDDCQRSΛಋೖ͢Δ͜ͱ͕తͰͳ͍͕ɺ ΑΓ҆શͰϝϯς͍͢͠ίʔυΛࢦͨ݁͠Ռ
͜ΕΒΛऔΓೖΕ͍ͨͱࢥͬͨ ·ͱΊ