Skip to content

Conversation

@MAG-mv
Copy link
Contributor

@MAG-mv MAG-mv commented Oct 27, 2025

This is part 1 of the server-side leader election work, which contains a new MultiplayerSystem which exposes the necessary functionality for leader election from the mcs MultiplayerServices api.

This work allows us to:

  • GetScopesInSpce - This is needed to get the current scope information
  • UpdateScope - This is needed to be able to turn on leader election
  • PerformLeaderElectionInScope- This is added for testing, as leader election is done automatically

While setting up the MultiplayerSystem, I ran into an issue with our URIs, which is fixed within this ticket. We were conflating the MultiplayerConnection Uri and the MultiplayerServices uri, which should be separate. This has been fixed by creating 2 separate uris. and also applying the root uri transform on both uris, as they both need this.

@MAG-mv MAG-mv requested a review from a team as a code owner October 27, 2025 10:50
@github-actions
Copy link

🚀 Pull Request Review Guidelines

Thank you for taking the time to review this Pull Request. The following is a summary of our Pull Request guidelines. The full guidelines can be found here.

💬 How to Provide Feedback

We use a comment ladder when leaving review comments to avoid any ambiguity.

Tag Is response required? Is a change required? May the PR author resolve?
[Fix] ✔️ ✔️
[Consider] ✔️ ✔️
[Question] ✔️
[Nit] ✔️
[Comment] ✔️

All comments should be prefixed with one of the above tags, for example:
[fix] Your editor is still set to use tabs instead of spaces, or this file is old and needs to be reformatted.

⚠️ Reviewers should be sure to resolve conversations if they feel their feedback has been addressed sufficiently.

🎯 PR Author Focus Areas

  • Link Commits to Conversations After making a change in response to a reviewer's comment, link the specific commit in the comment thread. This will allow the reviewer to view the change without having to hunt the codebase for it.
  • Breaking Changes Any breaking changes made to the public interface must be specifically called out in the PR. The preferred format is a bullet list enumerating the specific nature of the change/s, as well as the types and method signatures that are affected. If necessary, migration guidance should also be provided here.

Thanks again for taking the time to review this Pull Request.

Copy link
Contributor

@MAG-ElliotMorris MAG-ElliotMorris left a comment

Choose a reason for hiding this comment

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

Mostly doc stuff.

/// @brief Gets all scopes associated with the given space id.
/// @param SpaceId const csp::common::String& : The id of the space we want to get scopes for.
/// @param Callback csp::systems::ScopesResultCallback : Callback when asynchronous task finishes.
/// @pre Must already have entered the space of the SpaceId parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

[Consider] Stating what happens when this precondition is violated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: 2553f80

Copy link
Contributor

@MAG-ElliotMorris MAG-ElliotMorris Oct 31, 2025

Choose a reason for hiding this comment

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

[Comment] I still think this erroring behaviour is poor, an empty array of scopes is not a good marker for "You were not in the space", it could be caused by anything. I'm presuming we don't get a helpful error from CHS telling us why the request failed, which is what I'd ideally like.

[Question[ To give better errors, would we have to query CHS again to check if we're in the space beforehand? Seems like context the forwarded CHS response should be able to provide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: 9860b3d

Used the space system to check if we're in the space. We do this for HotspotSequenceSystem, as well.

CSP_ASYNC_RESULT void GetScopeLeader(const csp::common::String& ScopeId, ScopeLeaderResultCallback Callback);

/// @brief Starts leader election for the given scope.
/// This should not need to be called outside of testing, as leader election is done automatically.
Copy link
Contributor

Choose a reason for hiding this comment

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

[Consider] Maybe we should do the __ thing for the naming that we've been talking about for this? Heck, i'd even feature flag it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: 2553f80 by setting these types NO_EXPORT, until we understand how scopes are going to be used in CSP

Copy link
Contributor

Choose a reason for hiding this comment

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

[Question] I was under the impression we agreed on the __ naming convention for methods that only make sense in a test context going forwards. Am I mistaken in my understanding of either our new standard or what this method is? We can't just agree to do things and then not do them. I'm fine with this code, but you'll need to bring a reason why you didn't want to use the naming convention to the next sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in: 16e3767


void MultiplayerSystem::GetScopesBySpace(const csp::common::String& SpaceId, ScopesResultCallback Callback)
{
constexpr const char* ReferenceType = "GroupId";
Copy link
Contributor

Choose a reason for hiding this comment

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

[Consider] Thinking of/Finding a central location for magic strings like this (Unless it is specific to just this method). At least doc why this is what it is/is it arbitrary or magic, if nothing else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added docs. I can't think of any other magic string, and I dont ant to create a file for one string at this point. f99c3dd

Copy link
Contributor

Choose a reason for hiding this comment

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

[Consider] The most important piece of information about this string is whether it is magic or not, ie, could you put anything here, or does it relate to other data? Ie is it something that CHS or we populate so it has to say exactly "GroupId". That's not expressed in the comment.

}

// Ensure default scope has correct default values.
const csp::systems::Scope& DefaultScope = GetScopesResult.GetScopes()[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

[Question] Does CHS guarantee the order scopes are returned in, e.g. these are not ordered by last modified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure, but there is always 1 default scope, currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check with MCS as a precaution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeromagnopus How are the scopes retrieved from /scopes/referenceType/{referenceType}/referenceId/{referenceId} ordered?

Comment on lines +259 to +294
if (GetScopesResult.GetScopes().Size() != 1)
{
FAIL();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[Question] This assumes that the only scope being returned is the default; it is possible that in the future we may have several scopes by default, which would cause this test to be invalid. Do we know if any additional scope is intended to be introduced? (Thinking that POI could have an impact here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None that I know of. However, I think this is useful to keep here so we know that the behaviour has been changed

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check with MCS as a precaution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeromagnopus Do you know of any additional default scopes that will be created?

@MAG-mv MAG-mv force-pushed the OF-1784-server-side-election branch from 641d1f3 to 65e9952 Compare October 27, 2025 13:34
We were previously conflating the multiplayer hub uri and the multiplayer service uri, which require different values, but also a both have the same change to the RootUri. 2 seperate uris have now been setup to represent the 2

The helper function has also been updated which transforms the RootUri to be generic, so it can be used for both multiplayer uris
This adds a multiplayey system where we can put functionality from the chs multiplayer service api. We may want to make other system abstractions in the future, as this api contains a lot of different functionality. For now, only the functions needed for testing leader election have been implemented
Copy link
Contributor

@MAG-ChristopherAtkinson MAG-ChristopherAtkinson left a comment

Choose a reason for hiding this comment

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

Approved on the understanding that the open question will be answered.

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.

4 participants