Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(policy): compute desired number of matches before rooms #654

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ func (p *Policy) CalculateDesiredNumberOfRooms(policyParameters autoscaling.Poli
return -1, errors.New("There are no runningMatches in the currentState")
}

maxMatches := currentState[MaxMatchesKey].(int)
maxMatchesPerRoom := currentState[MaxMatchesKey].(int)

occupiedRooms := math.Ceil(float64(runningMatches) / float64(maxMatches))
desiredNumberOfRoom := int(math.Ceil(float64(occupiedRooms) / (float64(1) - readyTarget)))
desiredNumberOfMatches := math.Ceil(float64(runningMatches) / (float64(1) - readyTarget))
desiredNumberOfRooms := int(math.Ceil(desiredNumberOfMatches / float64(maxMatchesPerRoom)))

return desiredNumberOfRoom, nil
return desiredNumberOfRooms, nil
}

func (p *Policy) CanDownscale(policyParameters autoscaling.PolicyParameters, currentState policies.CurrentState) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1/rooms.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/api/v1/rooms.proto
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ message UpdateRoomStatusRequest {
string status = 4;
// Timestamp of the status update.
int64 timestamp = 6;
// The number of running_matches in the game room.
// The number of running matches in the game room.
int64 running_matches = 7;
}

Expand Down
2 changes: 1 addition & 1 deletion proto/apidocs.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@
"runningMatches": {
"type": "string",
"format": "int64",
"description": "The number of running_matches in the game room."
"description": "The number of running matches in the game room."
}
},
"description": "The player event request."
Expand Down
Loading