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
400
20220928-golang-meetup-di-fx_release_.pdf
Ken Chen
September 28, 2022
Tweet
Share
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Context Engineering - Making Every Token Count
addyosmani
9
670
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
30 Presentation Tips
portentint
PRO
1
230
The Spectacular Lies of Maps
axbom
PRO
1
530
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
120
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
310
Why Our Code Smells
bkeepers
PRO
340
58k
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