Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 1m40s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 42m16s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package model
|
|
|
|
// SelectionTrace is populated by the selector while its candidate snapshot is
|
|
// still locked. It never retains Channel objects, keys or provider settings.
|
|
type SelectionTrace struct {
|
|
Candidates []SelectionCandidate `json:"candidates"`
|
|
Total int `json:"candidate_total"`
|
|
SelectedID int `json:"-"`
|
|
}
|
|
|
|
type SelectionCandidate struct {
|
|
ChannelID int `json:"channel_id"`
|
|
Name string `json:"name"`
|
|
Group string `json:"group"`
|
|
Model string `json:"model"`
|
|
Priority int64 `json:"priority"`
|
|
Weight int `json:"weight"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
func (t *SelectionTrace) Add(ch *Channel, id int, group, model, reason string) {
|
|
if t == nil {
|
|
return
|
|
}
|
|
t.Total++
|
|
if len(t.Candidates) >= 100 {
|
|
return
|
|
}
|
|
c := SelectionCandidate{ChannelID: id, Group: group, Model: model, Reason: reason}
|
|
if ch != nil {
|
|
c.Name = ch.Name
|
|
c.Priority = ch.GetPriority()
|
|
c.Weight = ch.GetWeight()
|
|
}
|
|
t.Candidates = append(t.Candidates, c)
|
|
}
|
|
|
|
func (t *SelectionTrace) Finish(ch *Channel) {
|
|
if t == nil || ch == nil {
|
|
return
|
|
}
|
|
t.SelectedID = ch.Id
|
|
for i := range t.Candidates {
|
|
c := &t.Candidates[i]
|
|
if c.ChannelID == ch.Id && c.Reason == "eligible" {
|
|
c.Reason = "selected"
|
|
}
|
|
if c.Reason == "eligible" && c.Priority != ch.GetPriority() {
|
|
c.Reason = "different_priority"
|
|
}
|
|
}
|
|
}
|