-
Notifications
You must be signed in to change notification settings - Fork 77
Put together a slightly different worker model #844
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General thoughts - quite like the direction this is going but think we can consolidate some of the abstractions.
|
||
private ReceptionistConfig? receptionistConfig; | ||
private LocatorConfig? locatorConfig; | ||
private AlphaLocatorConfig? alphaLocatorConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wish we have C# unions 😕
Alternatively - perfect use case for https://github.com/mcintyre321/OneOf but sadly external dependencies 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this a union if we really want to. I wasn't changing any of this code though, just rearranging it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think we can get rid of alpha locator though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, not of the alpha locator :P we could get rid of the locator, if you wanna reduce complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline - can't get rid of the locator.
{ | ||
var deploymentList = await GetDeploymentList(locator); | ||
|
||
var deploymentName = parameters.DeploymentListCallback(deploymentList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm - we should allow for the possibility that this callback can be asynchronous.
I.e - user displays to the client and they select a deployment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably don't want that. the login token that is provided by the launcher will most likely time out by the time the user selects a deployment.
If users want to do that, they need to add quite a bit of additional logic and will most likely need to use the alpha locator together with dev auth flow or their own auth server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just rearranging what was there. If we can't select a deployment without a token and we can't keep a token after selecting a deployment that is a problem though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I had many discussions about this...
string workerType, | ||
ILogDispatcher logger, | ||
Vector3 origin) | ||
public static async Task<Worker> CreateWorkerAsync(IConnectionHandlerBuilder connectionHandlerBuilder, string workerType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like the connection builder should be extended into a WorkerBuilder
. I.e. -
var worker = await new WorkerBuilder(workerType)
.WithConnectionConfig(connectionConfig)
.WithLogger(logDispatcher)
.AsMultithreaded()
.ConnectAsync();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do that because you might want different types of connection handler. The IConnectionHandlerBuilder interface is basically a type safe way of transferring ownership.
The current connection handler builder is to build the standard one you might one when running spatial. If you want a test one or a remoting one you want different options. We could write one massive builder that can encompass every useful permutation but that seems like a bad idea even if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could instead set it up so that there is a single connection handler with a pipeline of behaviours and we feed it in different way (ie what it considers the simulation can be rewritten). Then we can potentially just have a single builder and merge it with the worker creation process.
I have looked into doing this and have some rough design notes if you want to go over them. (It's also probably what I'd do if starting now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls send design notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently writing a doc for a slightly different version. Can go through that and work out how it might work in C# too.
|
||
return worker.Connection.GetWorkerId() == ownerId; | ||
var ownerId = updateSystem.GetComponent<OwningWorker.Snapshot>(entityId).WorkerId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you grab this off the updateSystem rather than the view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The view isn't currently public. The update system is how you access it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's bizarre
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically a stepping stone. Update system was written for something else. Made sense as an interface for a bit, and now doesn't. It's mostly why the class wasn't mentioned in the release notes. It would be best to remove it and make a new thing because it's just a badly named interface at the moment.
|
||
private static string GetConnectionFailureReason(Connection connection) | ||
{ | ||
return connection.GetConnectionStatusCodeDetailString() ?? "No reason found for connection failure"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this actually be null?
what about the status code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be. I didn't write this though, just moved it I think.
var chosenService = GetConnectionService(); | ||
var connectionParameters = GetConnectionParameters(workerType, chosenService); | ||
SpatialOSConnectionHandlerBuilder connectionHandlerBuilder = new SpatialOSConnectionHandlerBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we have the ConnectionHandlerBuilder
, it would be really nice to get rid of the WorkerConnector
. If we can make it a WorkerBuilder
as Jamie suggested, I think we can get rid of this and simply provide sample implementations of how to use it for PC vs Mobile.
This would allow us to finally get rid of the many levels of inheritance we have right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep Unity and non Unity separate. The worker connector is glue between the worker and Unity, so I suspect that some form of it will still be useful.
/// The origin of the worker in global Unity space. | ||
/// </summary> | ||
public readonly Vector3 Origin; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: empty line
3b4d754
to
a6b5bbe
Compare
Rebased the branch - logging appears to be broken and some functionality that was added since this PR was opened needs to be added back in |
a6b5bbe
to
f345370
Compare
Superseded by #981 |
* Added known issue to known-issues doc * Update known-issues.md * Update known-issues.md * Update SpatialGDK/Documentation/known-issues.md Co-Authored-By: aleximprobable <48994762+aleximprobable@users.noreply.github.com>
Description
Mocked up what a csharp GDK worker might look like.