對接技術方案Plan A
===
RTI、TP FE、TP BE交互情境
---
```sequence
Note left of RTI: E:TP FE取得資料
RTI->TP Frontend: GraphQL 訂閱S水
RT DB->TP Frontend: 建立連線,取得最新Config
Note right of TP Frontend: 顯示資料
Note left of RTI: E:數據源賠率更新
Note right of RTI: 沒有調賠,將數據源當成S水
RTI->TP Frontend: 賽事、賠率更新
Note right of TP Frontend: 顯示資料
Note left of RTI: E:操盤手調賠(成功)
TP Frontend->RT DB: 送出賠率調整(Config)
Note right of RT DB: Validator(待訂)
Note right of RT DB: 更新Config值
RT DB->TP Frontend: 調賠Response,取得版本號
Note right of TP Frontend: 顯示設定完成,賠率同步中
RT DB->RTI: 推送最新版本的Config
Note right of RTI: 數據源+Config後,得出S水
RTI->TP Frontend: 推送新S水
Note right of TP Frontend: 如果版本號相同,顯示賠率同步完成
Note right of TP Frontend: 如果版本號不同,繼續等待
Note right of TP Frontend: time out後,提示數據不同步
Note left of RTI: E:數據源賠率更新(需混水)
Note right of RTI: 數據源+Config後,得出S水
RTI->TP Frontend: 賽事、賠率更新
Note right of TP Frontend: 顯示資料
Note left of RTI: E:操盤手調賠(失敗)
TP Frontend->RT DB: 送出賠率調整(Config)
Note right of RT DB: Validator(待訂)
Note right of RT DB: 更新Config值(*失敗*)
RT DB->TP Frontend: 調賠Response,提示更新失敗
Note left of RTI: E:操盤手調賠(失敗)
TP Frontend->RT DB: 送出賠率調整(Config)
Note right of RT DB: Validator(待訂)
Note right of RT DB: 更新Config值
RT DB->TP Frontend: 調賠Response,取得版本號
Note right of TP Frontend: 顯示設定完成,賠率同步中
RT DB->RTI: 推送最新版本的Config(*失敗*)
Note right of TP Frontend: time out後,提示數據不同步
Note left of RTI: E:操盤手調賠(失敗)
TP Frontend->RT DB: 送出賠率調整(Config)
Note right of RT DB: Validator(待訂)
Note right of RT DB: 更新Config值
RT DB->TP Frontend: 調賠Response,取得版本號
Note right of TP Frontend: 顯示設定完成,賠率同步中
RT DB->RTI: 推送最新版本的Config
Note right of RTI: 數據源+Config後,得出S水(*失敗*)
Note right of TP Frontend: time out後,提示數據不同步
Note left of RTI: E:操盤手調賠(成功)
TP Frontend->RT DB: 送出賠率調整(Config)
Note right of RT DB: Validator(待訂)
Note right of RT DB: 更新Config值
RT DB->TP Frontend: 調賠Response,取得版本號
Note right of TP Frontend: 顯示設定完成,賠率同步中
RT DB->RTI: 推送最新版本的Config
Note right of RTI: 數據源+Config後,得出S水
RTI->TP Frontend: 推送新S水(*失敗*)
Note right of TP Frontend: time out後,提示數據不同步
```
### 主要問題:
- 前端可以直接更改Realtime DB的值
至少要在中間加上Validator,包括調賠規則&權限判斷
- 操盤手送出調賠後,除了調賠完成,還需等待S水更新
正常情況下,誤差很短,可以讓前端先鎖著,S水更新後才提示修改成功
但如果timeout,只能提示操盤手數據不同步,此時只能聯繫TCS
- TP FE直接對接Realtime DB Config
當數據不同步時,賠率是舊版本,但config是新版本,容易混淆
- TP FE由RTI GraphQL取得Config
GraphQL需要增加回傳Config
如果該GraphQL也會開放給inno串接,Config需要對inno隱藏
- 系統架構相對複雜,一個操作行為,有可能兩套系統都需要參與,還有共同管理、使用的Realtime DB
- 新需求開發,需要兩組同步專案進度&資源,測試需要兩套系統連動測試,deploy時也需要注意更新的先後順序
### 優點:
- 數據源一更新,馬上混水即可得出S水