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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
190
Crafting Experiences
bethany
1
50
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
750
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
Amusing Abliteration
ianozsvald
0
100
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Visualization
eitanlees
150
17k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
The SEO identity crisis: Don't let AI make you average
varn
0
330
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
Agile that works and the tools we love
rasmusluckow
331
21k
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