code-corps / code-corps/code-corps-api
UserService might need to become an async task
- 主要語言
- Elixir
- 星號
- 234
- 分支
- 82
- PR 合併指標
- 30 天內沒有已合併 PR
描述
# Problem
Right now, the user service does the following in a single transaction
- updates the user
- updates the associated platform customer record locally
- updates the associated platform customer record on stripe
- updates the associated connect customer records locally (can be multiple)
- updates the associated connect customer records on stripe (can be multiple)
That's a lot of work for a synchronous process. It would make sense to make it an async task.
However, this process is triggered by the user updating their profile, so we do need to update the user record itself immediately, and reply with the updated record to the client.
This means that, in order to make it an async task, we would have to lose the benefits of it being a transaction.
Taking that into consideration, we need to discuss a potential solution (if we need to change anything at all).
One option would be to add a flag to the user database indicating that the account is out of sync with the associated stripe accounts. We could then periodically retry in a background worker of some sort.
Alternatively, a more encompassing solution would be to store background tasks somewhere and retry the failed ones. Really, I'm not sure what the proper way of dealing with this in Elixir would be, compared to Rails.
貢獻指南
研究方向
首先,從使用者個人資料更新的進入點開始,追蹤 UserService 經過 issue 中描述的本機更新和 Stripe 客戶更新。先釐清是否應替換 transaction,以及偏好哪種 retry 方法;完成的條件是有一個達成共識的設計,在保留對使用者的即時回應的同時,定義可靠處理失敗外部更新的方式。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- elixir
- 領域
- backend, payments
- Issue 類型
- 重構
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100