feat(matchmaker): migrate config to dedicated system storage#297
feat(matchmaker): migrate config to dedicated system storage#297thesprockee wants to merge 2 commits intomainfrom
Conversation
- Move GlobalMatchmakingSettings and SkillRatingSettings to EVRMatchmakerConfig - Store in SystemConfig collection with system-only write permissions - Organize 43 fields into 10 logical sub-config groups: * TimeoutConfig (3 fields) * BackfillConfig (4 fields) * ReducingPrecisionConfig (2 fields) * SkillBasedMatchmakingConfig (12 fields) * DivisionConfig (2 fields) * EarlyQuitConfig (5 fields) * ServerSelectionConfig (4 fields) * QueryAddons (6 fields) * DebugConfig (2 fields) * PriorityConfig (2 fields) * SkillRatingConfig (4 fields + nested RatingDefaults) - Add comprehensive validation (12 rules covering ranges, thresholds, percentages) - Implement atomic pointer access pattern matching ServiceSettings - All ~50+ call sites migrated to EVRMatchmakerConfigGet() - Maintain backward compatibility: old fields kept in ServiceSettingsData for existing stored configs - Remove unused UseSkillBasedMatchmaking() method - Add unit tests verifying defaults and validation Files changed: - NEW: server/evr_matchmaker_config.go (422 lines) - Config structure, validation, storage - NEW: server/evr_matchmaker_config_test.go (292 lines) - Unit tests - MODIFIED: server/evr_global_settings.go - Integration and backward compat - MODIFIED: 20+ server/evr_*.go files - Migrated to use EVRMatchmakerConfigGet() BREAKING CHANGE: None - old fields remain for backward compatibility during transition
- Document before/after usage patterns - Explain 11 config group organization - List all 12 validation rules - Provide RPC endpoint documentation - Include rollback and future cleanup plans - Confirm zero breaking changes with backward compatibility
There was a problem hiding this comment.
Pull request overview
This PR migrates matchmaker configuration from embedded fields in ServiceSettingsData to a dedicated EVRMatchmakerConfig structure stored in system storage. The migration reorganizes 43 configuration fields into 10 logical groups (timeout, backfill, SBMM, divisions, early quit, server selection, query addons, debugging, priority, and skill rating) with comprehensive validation rules.
Changes:
- Introduces new
EVRMatchmakerConfigstructure with atomic pointer-based access pattern (EVRMatchmakerConfigGet()/EVRMatchmakerConfigSet()) - Migrates ~50+ call sites across 24 files from
ServiceSettings().Matchmaking.*andServiceSettings().SkillRating.*to the new config accessors - Maintains full backward compatibility by preserving old struct fields and ensuring RPC endpoints return the same response format
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| server/evr_matchmaker_config.go | New 422-line config structure with validation, defaults, and storage operations |
| server/evr_matchmaker_config_test.go | Unit tests for defaults, validation, serialization, and atomic access |
| server/evr_global_settings.go | Integration of new config loading and backward compatibility preservation |
| server/evr_runtime_rpc_matchmaker_config.go | RPC endpoint migration to new config structure |
| server/evr_runtime_rpc.go | MatchmakingSettingsRPC converts new config to old format for backward compatibility |
| server/evr_runtime_rpc_match.go | Match allocation updated to use new config |
| server/evr_runtime_event_remotelogset.go | Post-match event processing migrated with graceful nil handling |
| server/evr_matchmaker_ratings.go | Rating calculation functions updated to use new config |
| server/evr_matchmaker_process.go | Match processing logic migrated with appropriate nil checks |
| server/evr_matchmaker.go | Matchmaker state capture logic updated |
| server/evr_match.go | Match lifecycle and early quit handling migrated |
| server/evr_lobby_parameters.go | Critical path updated with early error return on nil config |
| server/evr_lobby_matchmake.go | Matchmaking logic migrated with default fallbacks |
| server/evr_lobby_find.go | Lobby finding logic updated with nil-safe checks |
| server/evr_lobby_create.go | Lobby creation updated to use new config |
| server/evr_lobby_builder.go | Server allocation and backfill logic comprehensively migrated |
| server/evr_lobby_backfill.go | Backfill scoring and processing updated with new config structure |
| server/evr_pipeline_login.go | Login flow green division assignment updated |
| server/evr_earlyquit.go | Early quit penalty logic migrated with nil safety |
| server/evr_discord_appbot_handlers.go | Discord bot match allocation commands updated |
| server/evr_pipeline_matchmaker_test.go | Test updated to properly save/restore config state |
| server/evr_matchmaker_waittime_test.go | Wait time priority test migrated to new config pattern |
| server/evr_discord_integrator_platform_roles_test.go | Minor formatting/alignment change (benign) |
| docs/matchmaker-config-migration.md | Comprehensive 258-line migration guide |
| return | ||
| } | ||
| if tt.wantErr && err != nil && tt.errMsg != "" { | ||
| if err.Error()[:len(tt.errMsg)] != tt.errMsg { |
There was a problem hiding this comment.
This string slicing operation can panic if the error message is shorter than the expected message. Use strings.HasPrefix instead or check the length before slicing to prevent potential panics in tests.
| } | ||
| if c.EarlyQuit.EarlyQuitTier2Threshold != nil && *c.EarlyQuit.EarlyQuitTier2Threshold > 0 { | ||
| return fmt.Errorf("early_quit_tier2_threshold must be <= 0, got %d", *c.EarlyQuit.EarlyQuitTier2Threshold) | ||
| } |
There was a problem hiding this comment.
The validation should check that EarlyQuitTier1Threshold >= EarlyQuitTier2Threshold when both are set. Based on the defaults (-3 and -10), Tier1 should be greater than or equal to Tier2 since it represents better standing. Without this check, an invalid configuration like Tier1=-10, Tier2=-3 would pass validation but could cause logic errors.
| } | |
| } | |
| if c.EarlyQuit.EarlyQuitTier1Threshold != nil && c.EarlyQuit.EarlyQuitTier2Threshold != nil && | |
| *c.EarlyQuit.EarlyQuitTier1Threshold < *c.EarlyQuit.EarlyQuitTier2Threshold { | |
| return fmt.Errorf("early_quit_tier1_threshold must be >= early_quit_tier2_threshold, got tier1=%d tier2=%d", | |
| *c.EarlyQuit.EarlyQuitTier1Threshold, *c.EarlyQuit.EarlyQuitTier2Threshold) | |
| } |
Summary
Migrates matchmaker configuration from
ServiceSettingsDatato a dedicatedEVRMatchmakerConfigstructure stored in system storage. This provides better organization, validation, and separation of concerns while maintaining full backward compatibility.Changes
Core Implementation
New Config Structure: Created
EVRMatchmakerConfigwith 43 fields organized into 10 logical groups:Storage: System storage (Collection="SystemConfig", Key="matchmaker", Read=2, Write=0)
Atomic Access: Thread-safe with
EVRMatchmakerConfigGet()andEVRMatchmakerConfigSet()Validation: 12 comprehensive rules covering ranges, thresholds, and percentages
Tests: Unit tests verifying defaults, validation, serialization, and atomic access
Migration Scope
ServiceSettings().Matchmaking.*andServiceSettings().SkillRating.*Backward Compatibility
MatchmakingandSkillRatingfields preserved inServiceSettingsDataFixDefaultServiceSettingsmaintains old field initializationDocumentation
docs/matchmaker-config-migration.mdTesting
make nakamago test -short -vet=off ./server -run TestEVRMatchmakerConfiggofmtBreaking Changes
None - Full backward compatibility maintained:
Future Work
After sufficient migration period (1-2 releases):
GlobalMatchmakingSettingsstructSkillRatingSettingsstructFixDefaultServiceSettingsFiles Changed
New
server/evr_matchmaker_config.go(422 lines) - Config, validation, storageserver/evr_matchmaker_config_test.go(292 lines) - Unit testsdocs/matchmaker-config-migration.md(258 lines) - Migration guideModified (Key)
server/evr_global_settings.go- Integration and backward compatserver/evr_lobby_parameters.go- Migrated usageserver/evr_lobby_builder.go- Migrated usageserver/evr_lobby_backfill.go- Migrated usageserver/evr_matchmaker_ratings.go- Migrated usage