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 }