feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
1 parent
aa6c3f50f4
commit
ceddfd3d6b
828 files changed
+122253
-13702
No files matched your search
@@ -0,0 +1,52 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user