5732bf3384
iotlcm-bot:独立飞书应用机器人(读取 Worker 终态 Run JSON,渲染并发送全量同步结果卡片)。
- Go module:git.5iot.com/iotlcm/iotlcm-bot → git.5iot.com/iotlcm-public/iotlcm-bot
- 飞书凭据占位:appId/appSecret/chatId → ${FEISHU_APP_ID}/${FEISHU_APP_SECRET}/${FEISHU_CHAT_ID}
- 移除内部资产:CI 触发器
- Dockerfile 改用公共基础镜像(golang:1.25-alpine → scratch)
- README 重写(命令/配置/挂载契约/常见问题),去掉内部环境路径
- 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package archive
|
|
|
|
import "encoding/json"
|
|
|
|
type SupplyWait struct {
|
|
Count int64 `json:"count"`
|
|
TotalMS int64 `json:"totalMs"`
|
|
LongestMS int64 `json:"longestMs"`
|
|
}
|
|
type SupplyChannel struct {
|
|
Key string `json:"chanKey"`
|
|
Startup SupplyWait `json:"startupWait"`
|
|
Confirmed SupplyWait `json:"confirmedWait"`
|
|
Unconfirmed SupplyWait `json:"unconfirmedIdle"`
|
|
UnknownMS int64 `json:"unknownMs"`
|
|
Stages map[string]int64 `json:"producerStageMs"`
|
|
}
|
|
type SupplySummary struct {
|
|
UnknownMS int64 `json:"unknownChannelMs"`
|
|
UnconfirmedMS int64 `json:"unconfirmedChannelMs"`
|
|
ConsumerMS int64 `json:"consumerStartupChannelMs"`
|
|
Targets int `json:"targetChannels"`
|
|
Valid int `json:"validChannels"`
|
|
Confirmed int `json:"confirmedChannels"`
|
|
Unknown int `json:"unknownChannels"`
|
|
TotalMS int64 `json:"confirmedChannelMs"`
|
|
LongestMS int64 `json:"longestMs"`
|
|
}
|
|
type Supply struct {
|
|
SchemaVersion int `json:"schemaVersion"`
|
|
ResolutionMS int `json:"resolutionMs"`
|
|
Partial bool `json:"partial"`
|
|
Truncated bool `json:"truncated"`
|
|
Summary SupplySummary `json:"summary"`
|
|
Channels []SupplyChannel `json:"channels"`
|
|
}
|
|
|
|
func (r RunSummary) Supply() (*Supply, bool) {
|
|
if len(r.SupplyObservation) == 0 || string(r.SupplyObservation) == "null" {
|
|
return nil, false
|
|
}
|
|
var s Supply
|
|
if json.Unmarshal(r.SupplyObservation, &s) != nil || s.SchemaVersion != 1 || s.ResolutionMS != 1000 || s.Summary.Targets < 0 || s.Summary.Valid < 0 || s.Summary.Valid > s.Summary.Targets || s.Summary.TotalMS < 0 || s.Summary.LongestMS < 0 {
|
|
return nil, true
|
|
}
|
|
return &s, true
|
|
}
|