mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix(multiplayer): propagate allocated playlist
This commit is contained in:
@@ -59,10 +59,14 @@ func (w Worker) RunOnce(ctx context.Context) (bool, error) {
|
||||
// template. They are derived only from the durable match plan, never client
|
||||
// input or mutable worker configuration.
|
||||
func AllocationLabels(request domain.AllocationRequest) map[string]string {
|
||||
return map[string]string{
|
||||
labels := map[string]string{
|
||||
"cosmic-clash.io/region": request.Region,
|
||||
"cosmic-clash.io/build": request.Build,
|
||||
"cosmic-clash.io/protocol": strconv.Itoa(request.Protocol),
|
||||
"cosmic-clash.io/transport": request.Transport,
|
||||
}
|
||||
if request.Playlist != "" {
|
||||
labels["cosmic-clash.io/playlist"] = string(request.Playlist)
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
@@ -85,3 +85,10 @@ func TestAllocationLabelsMirrorFleetCompatibilityTuple(t *testing.T) {
|
||||
t.Fatalf("labels=%v want=%v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllocationLabelsCarryPlaylistWhenKnown(t *testing.T) {
|
||||
labels := AllocationLabels(domain.AllocationRequest{Playlist: domain.Ranked, Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"})
|
||||
if labels["cosmic-clash.io/playlist"] != string(domain.Ranked) {
|
||||
t.Fatalf("playlist label = %q, want %q", labels["cosmic-clash.io/playlist"], domain.Ranked)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user