Currently, as of v0.1.0-rc.6
, it is impossible to have complex microservice dependencies. If microservice A depends on microservice B, and microservice B depends on microservice C, there is no way for each respective microservice to wait for the microservices that it depends on to be running. There should be APIs to allow for this type of behavior to happen.
Real world use-case:
CameraController
depends on PlayerController:GetSetting("CameraLockedToMouse")
, which depends on DataController:GetData()
.
In this case, since all services have Start()
called in a non-specific order, the reference to DataController
is not guaranteed to exist when PlayerController:GetSetting()
is called, since PlayerController
has only been initialized so far:
function PlayerController:GetSetting(SettingName)
local PlayerData = DataController:GetData(true)
return PlayerData.Settings[SettingName].Value
end
function PlayerController:Start()
self:DebugLog("[Player Controller] Started!")
DataController = self:GetController("DataController")
end
In this scenario, DataController
will have to be fully running first, then PlayerController
, and then CameraController
.
Perhaps there should be some sort of config option that lets microservices specify their dependencies, and the framework will then calculate the order in which to load & run the microservices? E.g. CameraController
specifies that it depends on a controller named "PlayerController", and PlayerController
specifies that it depends on a controller named "DataController". The framework gets all of this information, and then loads everything sequentially, in the specified order.