Skip to content

feat(gameye): configurable environments, DI config, multi-port, and region routing - #24

Merged
FelixWentworth-Unity merged 4 commits into
Unity-Technologies:mainfrom
capt-marbles:feat/gameye-config-and-region-routing
Jun 8, 2026
Merged

feat(gameye): configurable environments, DI config, multi-port, and region routing#24
FelixWentworth-Unity merged 4 commits into
Unity-Technologies:mainfrom
capt-marbles:feat/gameye-config-and-region-routing

Conversation

@capt-marbles

Copy link
Copy Markdown
Contributor

Description

Upgrades the GameyeAllocator with four improvements that make it production-ready without requiring users to edit implementation code.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security fix
  • Performance improvement

Provider Integration

  • GameLift
  • Multiplay
  • PlayFab
  • Multiplay by Rocket Science
  • New Provider Integration
  • General/Infrastructure
  • Gameye
  • Documentation

Changes Made

1. DI-based configuration (GameyeAllocatorConfig)
Replaces the hardcoded const fields with a GameyeAllocatorConfig singleton registered in ModuleConfig.Setup(). Users edit one config block — no hunting for const lines in the implementation.

2. Configurable environments (GameyeEnvironment enum)
Adds Sandbox and Production enum values. ApiBaseUrl is computed from the enum so there are no raw URL strings to typo. Defaults to Sandbox (safe default for new integrations).

3. Automatic region selection (LocationByRegion + LocationByPool)
Three-tier region resolution priority:

  1. MatchProperties["Region"]LocationByRegion (Unity QoS resolved region — preferred, no per-region pools needed)
  2. PoolNameLocationByPool (pool-name mapping for studios using per-region pools without QoS)
  3. DefaultLocation (static fallback)

Uses "Region" (capital R) to match the convention established in PR #21 and the empty-string guard from PR #23.

4. Version field and additional ports

  • Version on SessionRequest with NullValueHandling.Ignore — omitted from JSON when null, preserving Gameye's "use highest priority tag" default
  • AdditionalPorts dictionary — extra ports (e.g. query, RCON) returned in AllocationData as port_{name} entries alongside the primary port

Testing

  • Tested with actual provider integration
  • Added/updated unit tests
  • Verified no breaking changes

21 NUnit tests covering: basic allocation, environment URL selection, version field (present/omitted), additional ports, all three region resolution paths (QoS wins over pool, pool wins over default, empty Region string falls back), poll fast-path and API fallback, all Gameye status → PollStatus mappings, error handling.

Security Checklist

  • No credentials, API keys, or secrets committed
  • Reviewed all changes for sensitive data
  • No credentials are hardcoded — all auth flows through Unity Secret Manager (GAMEYE_API_TOKEN)

Code Provenance

  • All code is original work created by me
  • I have the right to submit this code under the Unity Companion License
  • I did not copy code verbatim from provider documentation without attribution
  • No proprietary or confidential code is included
  • All third-party code is properly attributed and licensed

License Agreement

  • I agree to license my contributions under the Unity Companion License
  • I understand that Unity retains all rights to contributed code as specified in the license
  • I have read and agree to the terms in CONTRIBUTING.md

Documentation

  • Updated CONFIGURATION.md for affected modules

Provider Terms Compliance

  • Changes do not violate provider terms of service
  • Provider names used descriptively without implying endorsement

Community Support Acknowledgment

  • I understand this is a community-driven project
  • I understand reviews are conducted on a best-effort basis
  • I am willing to address review feedback

…n routing

Replaces hardcoded constants with a GameyeAllocatorConfig singleton registered
in ModuleConfig.Setup(), making the allocator configurable without touching
implementation code. Adds automatic region selection from Unity QoS
MatchProperties["Region"] as a priority-1 path above LocationByPool.

Changes:
- GameyeAllocatorConfig: DI-registered config class (ImageName, Environment,
  DefaultLocation, GamePort, Version, AdditionalPorts, LocationByPool,
  LocationByRegion)
- GameyeEnvironment enum: Sandbox / Production — ApiBaseUrl computed from enum,
  no raw URL strings to typo
- Three-tier region resolution: MatchProperties["Region"] → LocationByRegion →
  PoolName → LocationByPool → DefaultLocation
- Version field on SessionRequest with NullValueHandling.Ignore (omitted from
  JSON when null, preserving "use highest priority tag" default)
- AdditionalPorts: extra ports included in AllocationData as port_{name} entries
- Tests updated to NUnit/Moq style matching repo conventions; 21 Gameye tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Maps Unity Matchmaker **pool names** to Gameye location IDs, enabling dynamic region selection per match. When the matched pool is found in this dictionary, that location is sent to Gameye instead of `DefaultLocation`. Pools not in the map fall through to `DefaultLocation`.

Unity Matchmaker uses pools for region routing — create one pool per region in your queue configuration, then mirror that mapping here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Unity Matchmaker uses pools for region routing — create one pool per region in your queue configuration, then mirror that mapping here.
Unity Matchmaker can be configured to use pools for region routing — create one pool per region in your queue configuration, then mirror that mapping here.

Using this pool-to-region mapping is a decision made by the game dev to not use QoS. The original statement can be understood as something Unity Matchmaker strictly does, which is not true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — you're right that pool-based routing is a developer decision (an alternative to Unity QoS), not something Matchmaker strictly does. Reworded to "can be configured to use pools for region routing" in 4a05258. Thanks!

capt-marbles and others added 2 commits June 2, 2026 22:05
Address review feedback from @lucy-yuan: pool-to-region mapping is a
developer decision (used instead of Unity QoS), not behavior Matchmaker
strictly performs. Reword to 'can be configured to use pools'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Environment defaults to Sandbox, which is easy to leave unset when going
live. Rather than silently routing production matchmaking traffic to
sandbox infrastructure, the allocator now logs the active environment on
every allocation: a WARNING in Sandbox (with a reminder to set
Production) and an INFO confirmation in Production.

- GameyeAllocator.Allocate: log active environment + ApiBaseUrl
- CONFIGURATION.md: callout that Environment defaults to Sandbox and the
  allocator warns until switched to Production
- Tests: assert the Sandbox warning fires and Production logs info with
  no warning; clear logger invocations per test (shared NUnit fixture)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FelixWentworth-Unity
FelixWentworth-Unity self-requested a review June 5, 2026 12:59
config.Dependencies.AddSingleton(new GameyeAllocatorConfig
{
// Required — the application image name registered in the Gameye Admin Panel.
ImageName = "test_nginx",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this name map to onboarding steps, in other allocators we use "your-image-name" to help make it clear users need to change this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, test_nginx reads like a concrete onboarding value. Updated it to your-image-name in 2bcd3c1 so it is clearly a placeholder users need to replace.

@FelixWentworth-Unity FelixWentworth-Unity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks for making the edits

@FelixWentworth-Unity
FelixWentworth-Unity merged commit dae5a6f into Unity-Technologies:main Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants