a9aa1a715fcd93b72bd0c1c1c8735b586143e418
sidecar.md
| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | +### sidecar启动以后定时10s执行以下业务逻辑 |
|
| 2 | + |
|
| 3 | + |
|
| 4 | +<details> |
|
| 5 | + <summary>点击展开puml</summary> |
|
| 6 | + |
|
| 7 | +```puml |
|
| 8 | +@startuml |
|
| 9 | +start |
|
| 10 | +:检查是否为master; |
|
| 11 | +if (configUtils.APP_NAME != configUtils.APP_MASTER_NAME) then (不是) |
|
| 12 | + stop |
|
| 13 | +else (是) |
|
| 14 | + :创建Kubernetes客户端; |
|
| 15 | + :获取Deployment列表; |
|
| 16 | + :获取StatefulSet列表; |
|
| 17 | + :合并Deployment和StatefulSet列表到allList; |
|
| 18 | + :从Dapr获取状态; |
|
| 19 | + if (appHashMap == null) then (是) |
|
| 20 | + stop |
|
| 21 | + else (不是) |
|
| 22 | + :同步app安装数据,初始化删除集合set; |
|
| 23 | + repeat |
|
| 24 | + :遍历appHashMap的每个键; |
|
| 25 | + if (状态 == "installing") then (是) |
|
| 26 | + :检查创建时间是否超过10秒; |
|
| 27 | + if (未超过10秒) then (是) |
|
| 28 | + endif |
|
| 29 | + endif |
|
| 30 | + repeat |
|
| 31 | + :遍历allList的每个对象; |
|
| 32 | + if (名称匹配) then (是) |
|
| 33 | + :获取replicas和readyReplicas; |
|
| 34 | + :更新appHashMap; |
|
| 35 | + :isdel = false; |
|
| 36 | + break |
|
| 37 | + endif |
|
| 38 | + repeat while (allList有更多对象) |
|
| 39 | + if (isdel) then (是) |
|
| 40 | + :将键添加到删除集合set中; |
|
| 41 | + endif |
|
| 42 | + repeat while (appHashMap有更多键) |
|
| 43 | + :从appHashMap中删除set中的键; |
|
| 44 | + if (storedEtag != null) then (是) |
|
| 45 | + :保存状态到Dapr(使用storedEtag); |
|
| 46 | + :记录错误日志; |
|
| 47 | + else (不是) |
|
| 48 | + :保存状态到Dapr; |
|
| 49 | + endif |
|
| 50 | + endif |
|
| 51 | +endif |
|
| 52 | +stop |
|
| 53 | +@enduml |
|
| 54 | + |
|
| 55 | + |
|
| 56 | +``` |
|
| 57 | +</details> |
|
| ... | ... | \ No newline at end of file |