Refactor: move service launchers to test code #879
josecelano
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Originated in: #268 (comment)
The API, UDP, and HTTP tracker use a similar strategy to run the service instances. There are two levels of logic:
ServiceControllerServiceLauncherServiceController
The
ServiceControlleris responsible for the following:config.toml) file.runningorstopped.It does not store the configuration changes. If you stop the service, the next time you start it it will use the initial configuration when the
ServiceControllerwas instantiated.ServiceLauncher
The
ServiceLauncheris responsible for the following:Current implementations
Tracker API:
torrust_tracker::servers::apis::server::ApiServer<S>(ServiceController)torrust_tracker::servers::apis::serverandtorrust_tracker::servers::apis::server::start_tlsfunctions (ServiceLauncher)HTTP tracker:
torrust_tracker::servers::http::server::HttpServer(ServiceController)torrust_tracker::servers::http::v1::launcherstartandtorrust_tracker::servers::http::v1::launcherstart_tlsfunctions (ServiceLauncher)UDP tracker:
torrust_tracker::servers::udp::server::UdpServer(ServiceController)torrust_tracker::servers::udp::server::Udp(ServiceLauncher)Proposed changes
Some structs are only used for testing for the time being. We should move them to test modules until we needed in production code. For example, if we add a feature to check the state of a given service (we could show all the services and the ports they are using in an admin panel).
Structs only used for testing:
torrust_tracker::servers::apis::server::ApiServer<S>(ServiceController)torrust_tracker::servers::http::server::HttpServer(ServiceController)torrust_tracker::servers::udp::server::UdpServer(ServiceController)Other dependencies are used only for testing too.
Future improvements
This is out of the scope of this issue, but maybe we could generalize a
ServiceControllerfor services that need a socket port, which is, I think, what they have in common.Beta Was this translation helpful? Give feedback.
All reactions