Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
20220928-golang-meetup-di-fx_release_.pdf
Search
Ken Chen
September 28, 2022
0
390
20220928-golang-meetup-di-fx_release_.pdf
Ken Chen
September 28, 2022
Tweet
Share
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Designing for Performance
lara
609
69k
Faster Mobile Websites
deanohume
307
31k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
480
Code Reviewing Like a Champion
maltzj
524
40k
Raft: Consensus for Rubyists
vanstee
140
7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Designing for humans not robots
tammielis
253
25k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Transcript
用 Fx 來替 Go 依賴注入吧 Ken Chen @ Golang Taiwan
Gathering #64 2022/9/29
## About Me - OneDegree Backend Engineer - Go Developer
- Modern Software Engineering - Cinema, Modern Literature / Sociology
## 讓我們看看今天的話題 - 依賴注入 - 作為應用框架的 Fx - Fx 的實現
- 使用上要注意的點
依賴注入的目的
## 相依性的來源 - Repo 創建物件後,交給 Us 使用 - 那能不能要更多東西? Usecase
Repository
Usecase Repository Database Schema ## 相依性的來源 - Repo 的物件會影響到程式邏輯 -
資料庫的 Schema 會影響到程式邏輯
None
## 切分子系統 - 每一層中間加上介面 - 實作優先轉為介面優先 Usecase Repository <<Interface>> Repository
None
講這麼多,要怎麼做
None
None
None
None
好像很簡單? 那是因為沒放入應用
None
Usecase A Usecase B Repository A Postgres Repository C Repository
B MongoDB Redis
Fx 是依賴注入的應用框架
None
None
None
None
今晚我想來點 Graceful Shutdown
None
None
None
有沒有可能預配置?
Instance A NewFunc B invoke Invoke Provide Supply
None
想要解構賦值的話呢?
None
None
覺得參數太多怎麼辦?
None
想要打包成模組的話呢?
NewFunc B Module Provide NewFunc A Instance A Supply
None
None
需要多個相同型別的實例
None
None
None
None
Fx 是如何打造的?
None
None
None
None
None
關於 Fx 使用上的反思
None
None
## 可能的處理方式 - 加入自定義的 logger - 初始化階段,失敗直接 panic - 建立公司內的工具包,降低導入成本
- 評估使用 Fx 對加速的幫助
謝謝大家 medium