-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
Area: devRelated to development environment or dev QoLRelated to development environment or dev QoLComplexity: easySuitable for contributors new to NitroxSuitable for contributors new to Nitrox
Milestone
Description
Describe the issue
Server code has the following code smells:
- Server starts and loads from files through DI container instead of what is conventional: loading after the DI container is fully resolved. Types registered in a DI container should not do IO until asked for by code that takes dependency on said types.
- The dependency-flow on data is inverted from what it should be (is parent->child but should be child->parent). Types like
WorldPersistenceshould take dependency onServer(which knows its SaveName) instead of recomputing the save location. The current situation has lead to awkward DI container setup where types need to run setup code to be able to register in the DI container. - Strongly related with 2: because file loading happens during DI container setup, cancellation of server is hard to implement (without first waiting for the server to fully load).
To assist with this refactor, the server should implement .NET Generic Host API.
Then:
- Rename the
Serverclass toServerService, extendingBackgroundService. Have it figure out the save name from command line arguments (passed to the server executable). - Create a
ConfigServicewhich depends onServerServiceand loads in the right server.cfg file based on the save name thatServerServiceknows. Any updates to the configuration should happen through thisConfigService. - Create a
WorldPersistenceServicewhich depends onServerServiceto figure out where it shouldLoad,SaveandBackupto. If there is no world, have it create one inWorldPersistenceService.StartupAsyncroutine. Add events/dependencies to other services as needed to trigger world backups or saving. - Create a
CommandServicethat will read from the command line and call the correct command on submit (i.e. enter pressed). - Continue creating APIs that depend on
ServerServiceor any other as needed...
PRs required before work can start
daygr and Gauvinodartasen and Gauvino
Metadata
Metadata
Assignees
Labels
Area: devRelated to development environment or dev QoLRelated to development environment or dev QoLComplexity: easySuitable for contributors new to NitroxSuitable for contributors new to Nitrox