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
-
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:
ServiceController
ServiceLauncher
ServiceController
The
ServiceController
is responsible for the following:config.toml
) file.running
orstopped
.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
ServiceController
was instantiated.ServiceLauncher
The
ServiceLauncher
is responsible for the following:Current implementations
Tracker API:
torrust_tracker::servers::apis::server::ApiServer<S>
(ServiceController
)torrust_tracker::servers::apis::server
andtorrust_tracker::servers::apis::server::start_tls
functions (ServiceLauncher
)HTTP tracker:
torrust_tracker::servers::http::server::HttpServer
(ServiceController
)torrust_tracker::servers::http::v1::launcherstart
andtorrust_tracker::servers::http::v1::launcherstart_tls
functions (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
ServiceController
for services that need a socket port, which is, I think, what they have in common.Beta Was this translation helpful? Give feedback.
All reactions