【得物技術】淺談資損防控

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"什麼是資損","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"資損通常來講是指支付場景下的資金損失,這裏可以從兩個維度看","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用戶角度:多扣用戶款導致用戶資金損失,此問題一般需要通過客服等渠道反饋,可以把多的錢退給用戶,但是很大程度上損失了用戶體驗;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"公司角度:主要是多出金、多出貨、多充值等情況,一般這種損失很難追回,這就是實打實的產生了資產損失。","attrs":{}}]}]}],"attrs":{}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d6/d6e021e72aeb149fe527a16e9342d857.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"比如對於一個電商業務可能涉及到上圖各種業務,業務之間都存在下發、回調、消息傳遞等各種邏輯或者狀態同步,如果其中由於一些交互操作丟失導致庫存異常、資金結算換算異常、單據流程未結束異常、邏輯觸發重複請求,併發控制處理不當等等,最終導致資產或資金的損失。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於情況預防手段除了事前的一些列嚴格測試,事後分析的優化補救,也可以通過事中進行監控,得物在這方面就是通過自研的DCheck進行防控。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"初識DCheck","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"此係統由“交易&穩定性”團隊主導的,主要是希望及時的發現數據的問題,保障數據穩定的運行,尤其是涉及到資損的場景,爲了做到實時有效的監控,在此背景下搭建了準實時覈對系統DCheck,此平臺基於Mysql的binglog監控,以及MQ的訂閱的信息流技術手段,通過配置觸發條件、規則和任務運行以及告警,來確保各個業務上下游業務間的狀態一致性,進出扣款金額計算後的準確性。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"深入DCheck","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"功能層級","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e2/e27a3daecf0726c3a0fbd818c933b3b2.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"架構邏輯","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9f/9f9398fcf178bb1a205e7a1635dc8323.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"概念","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"主題:邏輯數據庫 或 MQ訂閱","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"事件:Update/ Insert類型操作 或 MQ自定義消","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"子事件:事件所返回的數據的第一層過濾","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"腳本池:有filter和check兩個繼承方法,filter處理二層數據過濾,check業務上下游邏輯判斷","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"規則:觸發和檢測核心執行部分","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"DCheck","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於此係統的功能和使用簡單演示如下","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"覈對配置","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"主題管理","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/7a/7a3471387bacc9d8c52a92f2555dc550.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"TOPIC:庫名","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"主題編碼:表名","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"主題名稱:中文的表名","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MQ實例地址: 對於binlog填*","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"事件管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/00/000714a3f77ffd79d491426024c6ce81.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於binlog而言,分成了INSERT和UPDATE兩種,根據上主題配置自動生成無需創建","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"子事件管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/98/98a7140bfc384f6d7ad94efea8c19bb2.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"清洗的數據的過濾層,此處在規則配置中,返回‘TRUE’的纔會進入下一層,如:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"if( obj.status.toInteger() == 10000 && (obj.type.toInteger() ==101 || obj.type.toInteger() ==301) ) return 'TRUE';","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果想所有都返回,就直接 return 'TRUE'。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"腳本池管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所有被執行腳本使用的是groovy進行編寫的,主要是BaseScript實現filter 和 check兩個方法,內部可以參考腳本庫","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Filter ","attrs":{}},{"type":"text","text":"經過事件過濾後需要腳本再進行二次過濾的操作,主要是一些不能簡單從donCleanData進行判斷,需要進行正向逆向獲取其他數據,或是一些早爲複雜的邏輯。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Check ","attrs":{}},{"type":"text","text":"驗證邏輯處理方法,主要是就是進行上下游同步狀態驗證,複雜結果計算(尤其是進出帳扣款等方面)比較。","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"代碼例子:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"import com.alibaba.fastjson.JSON; \nimport com.alibaba.fastjson.JSONObject; \nimport groovy.util.logging.Slf4j; \nimport org.springframework.stereotype.Service; \n \nimport javax.annotation.Resource; \n \n/** \n * DCheck:冷靜期內-平臺客服取消訂單-退買家支付金額 \n */ \n@Slf4j \n@Service \nclass CheckRefundPayForLess30min implements BaseScript { \n \n @Resource \n private OrderDevOpsApi orderDevOpsApi; \n \n @Resource\n DCheckApi dCheckApi; \n \n @Resource \n private PayServiceFeignClient payServiceFeignClient \n \n String logTag = \"TAG_CheckCrossAndOverSeaRefundPayForLess30min:{}\" \n \n // 1.關單時間-支付時間<30分鐘 \n @Override \n boolean filter(JSONObject doneCleanData) { \n // 查詢支付時間 \n String unionId = doneCleanData.getString(\"order_no\"); \n String payTime = getOrderData(unionId,\"payTime\", DevOpsSceneEnum.FORWARD_PAY); \n long modifyTime = doneCleanData.getDate(\"modify_time\").getTime(); \n long diffTime = modifyTime - Long.valueOf(payTime) \n if (diffTime < 30 * 60 * 1000){ \n return true; \n } \n log.info(logTag,\"===>有符合數據進入Check\") \n return false; \n } \n \n @Override \n String check(JSONObject doneCleanData) { \n String subOrderNo = doneCleanData.getString(\"sub_order_no\"); \n Result> listResult = dCheckApi.queryPayNoBySubOrderNo(subOrderNo); \n if(listResult == null || listResult.getData() == null) { \n return \"根據正向查詢接口通過子訂單號查詢支付流水號數據爲空\"; \n } \n if(listResult.getData().size() > 1){ \n return \"根據正向查詢接口通過子訂單號查詢支付流水號多條數據,請查看是否需要優化邏輯\"; \n } \n \n String outPayNo = listResult.getData().get(0); \n RefundQueryRequest refundQueryRequest = new RefundQueryRequest(); \n refundQueryRequest.setPayLogNum(outPayNo); \n Result> resp = payServiceFeignClient.queryRefundsByPayLogNum(refundQueryRequest); \n // 判斷支付查詢數據是否爲空,如果爲空直接報數據錯誤,以及是否查詢到了多條數據 \n if (resp == null || resp.getData() == null) { \n return \"上游數據爲空:支付退款查詢(根據支付流水號)\"; \n } \n else if (resp.getData().size() != 1) { \n return \"上游數據爲多條請確認邏輯:支付退款查詢(根據支付流水號)\"; \n } \n \n // 檢查點邏輯判斷1: 狀態爲打款成功 \n if (resp.getData().get(0).getStatus() !=2 ){ \n return \"校驗支付打款狀態非2\"; \n } \n \n // 邏輯校驗點2:交易退款和RPC查詢的金額一致,否則告警 \n if (resp.getData().get(0).getAmount() != doneCleanData.getLong(\"amount\")) { \n return \"校驗交易退款金額和支付打款金額不一致\"; \n } \n return \"SUCCESS\"; \n } \n \n // 數據庫查詢對應字段值 \n String getOrderData(String unionNo,String key,DevOpsSceneEnum devOpsSceneEnum){ \n // 內部方法省略.... \n return value; \n } \n} ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"規則配置","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/2b/2bf59c8b93150e8d19fbb2d9c0322afa.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"規則配置爲上述所有基礎配置的組合以及真正的運行核心,主要兩大塊,基礎信息和降級策略。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"基礎信息","attrs":{}},{"type":"text","text":":子事件(支持搜索和多個選中)+ 腳本類(搜索選擇) = 觸發和執行邏輯","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其他爲輔助配置信息按照各自域和需求配置。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"降級策略","attrs":{}},{"type":"text","text":":","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"採樣百分比:線上流量採樣百分比,前期測試或者對業務有很大影響的需要控制流量,不能爲100%","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"首次延遲時間:觸發執行延遲時間,在業務流程,數據同步有些會有些延遲,爲了避免由於延遲導致的狀態不同步問題,建議設置一定的延遲比例,一般10秒左右","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最大超時時間和生效時間:規則有效時間配置","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"工具使用","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"覈對異常","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對check異常的數據,一般首先會發到配置的告警飛書羣和配置的個人,點擊即可跳轉到此頁面,主要看錯誤的具體數據,經確認後是腳本或者部分數據問題的,優化後“重發”可以標記爲處理,如果是確定是問題的,則定位“資損”問題。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Mock","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"由於本地腳本調用一些RPC接口,目前還沒有好的辦法能在本地進行debug,所以就需要通過先配置規則後,使用mock進行調試,主要用到的是規則調試,選擇指定的規則,搜索或者創造符合dcheck場景的json格式的請求參數,提交請求查看響應結果即可。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這裏有個問題,因爲dcheck內部邏輯對一些系統異常腳本做了統一處理,很多時候沒法看到具體的原因,就是失敗或者邏輯外通過,這就需要需要在腳本中多加些打印日誌,然後通過日誌平臺去查看具體邏輯問題。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"一些使用技巧","attrs":{}}]},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"規則配置技巧","attrs":{}}]}]}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"規則中事件是可以多選的,所以對於事件不同,但check相同或者相似的腳本處理邏輯可以歸併,減少規則維護量","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"觸發數據可以在事件進行配置的,儘量少用腳本filter處理,代碼一般處理需要非觸發數據外邏輯","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"2","normalizeStart":"2"},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"Groovy的閉包使用","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"腳本數據處理有會有很多list,key-value的處理,可以充分利用groovy的閉包特性,大大簡化java語言的複雜處理邏輯。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"舉例","attrs":{}},{"type":"text","text":":如果如下數據格式的結果返回objectList:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"[{id=10086, refundNo=RE10086, orderNo=100888, userId=15206, bizType=110, payTool=0, payStatus=404,amount=100, feature=, isDel=0, createTime=2021-05-11 21:39:34.000, modifyTime=2021-05-11 21:39:34.000, moneyFrom=1, currency=, countryCode=},{id=10087, refundNo=RE10087, orderNo=100999, userId=15206, bizType=202, payTool=0, payStatus=404, amount=400, feature=, isDel=0, createTime=2021-05-11 21:39:34.000, modifyTime=2021-05-11 21:39:34.000, moneyFrom=1, countryCode=}] ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1)filter進行條件判斷,可以使用any","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"def filterResult = objectList.any{it.bizType in [110,119] && it.payStatus == 404};","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"return filterResult","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2)check獲取某個符合條件的值,可以使用find","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"def mount = objectList.find{ it.type=5}.amount","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"更多groovy特性可以參考文章:","attrs":{}},{"type":"link","attrs":{"href":"https://www.jianshu.com/p/5d30f1443aa6","title":null,"type":null},"content":[{"type":"text","text":"https://www.jianshu.com/p/5d30f1443aa6","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"一些平臺不足","attrs":{}}]},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"沒有比較方便的調試方式","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前本地腳本庫沒有可以運行調試的環境,雖然有Mock工具,但也是需要先配置事件,上傳腳本配置後才能進行調試,同時腳本邏輯問題也需要去日誌不斷改腳本的加日誌的方式去查看,另外最後如果在測試環境了進行了調試通過,還要去線環境再重複配置一遍流程。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"建議","attrs":{}},{"type":"text","text":":線上在子事件、腳本、規則增加的頁面就增加一個Debug按鈕,可以直接通過給定參數或者抓取符合條件的一條數據進行調試給出結果,最好也能給出這部分日誌。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"2","normalizeStart":"2"},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"腳本池Filter和check方法放在一起會有很多冗餘","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在開發腳本和配置中發現其實好多filter邏輯相同,抑或check邏輯相同,但由於腳本中放在一起,就會產生交叉的邏輯編寫,無法做到有效的公共剝離。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"建議","attrs":{}},{"type":"text","text":":Filter 和 check 拆分,並且作爲公共的池,規則中單獨配置,更可以選擇模式爲引用或者導入,導入的支持主要方便邏輯大部分相同,個別參數不相同下快速修改配置規則上線。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"3","normalizeStart":"3"},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","text":"真的問題出現時沒有熔斷機制","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"雖然目前整個平臺的實際還待觀察,但其中後續如果平臺效果是很好的,真的發生大批量數據問題或者資金損失問題,平臺的機制也只是發生問題的警告,然後技術介入,本質上還是後置的處理的方式,如一開始講的這種後置的處理,並不能達到及時止損的目的。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"建議","attrs":{}},{"type":"text","text":":後續在平臺更加準確時,應該考慮與關鍵域熔斷聯動,及時制止損失的產生。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"4","normalizeStart":"4"},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","text":"平臺應該增上下線開關","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前規則的執行不執行,只能通過編輯控制流量0,或是執行時間來關閉,也沒有批量的,操作上有些不便。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"建議","attrs":{}},{"type":"text","text":":增加上下線開關,增加批量操作如:流量大小,開關,警告人等","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"5","normalizeStart":"5"},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":5,"align":null,"origin":null},"content":[{"type":"text","text":"平臺可以考慮增加流量的動態判斷機制","attrs":{}}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"由於好多check點是通過各個域的接口進行操作,在流量大的時候,尤其是關鍵的業務,可能對業務產品很大影響,或者在某接口兼容不好,系統異常導致大量非常規一場報錯的時候,各方人會炸掉。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"建議","attrs":{}},{"type":"text","text":":規則分等級,核心業務可以做高級配置,遇到上述問題觸發自動調節降流量,對於問題已恢復可自動增加流量。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"文|大奇","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"關注得物技術,攜手走向技術的雲端","attrs":{}}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章