Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: move service launchers to test code #274

Closed
josecelano opened this issue Apr 6, 2023 · 0 comments
Closed

Refactor: move service launchers to test code #274

josecelano opened this issue Apr 6, 2023 · 0 comments
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Needs Feedback What dose the Community Think?
Milestone

Comments

@josecelano
Copy link
Member

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:

  • The ServiceController
  • The ServiceLauncher

ServiceController

The ServiceController is responsible for the following:

  • Storing the configuration needed to start the service (contained from the config.toml) file.
  • Starting and stopping the service
  • Knowing the current state of the service: running or stopped.

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:

  • Starting the service instance.
  • Starting the service instance with a graceful shutdown. It can receive a shutdown signal.

Current implementations

Tracker API:

  • torrust_tracker::servers::apis::server::ApiServer<S> (ServiceController)
  • torrust_tracker::servers::apis::server and torrust_tracker::servers::apis::server::start_tls functions (ServiceLauncher)

HTTP tracker:

  • torrust_tracker::servers::http::server::HttpServer (ServiceController)
  • torrust_tracker::servers::http::v1::launcherstart and torrust_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.

@da2ce7 da2ce7 added - Developer - Torrust Improvement Experience Needs Feedback What dose the Community Think? and removed Enhancement / Feature Request Something New labels Oct 10, 2023
@cgbosse cgbosse moved this to Maintenance in Torrust Solution Jan 8, 2024
@cgbosse cgbosse moved this from Maintenance to Help Wanted in Torrust Solution Jan 11, 2024
@cgbosse cgbosse added this to the v3.1.0 milestone May 24, 2024
@torrust torrust locked and limited conversation to collaborators May 24, 2024
@cgbosse cgbosse converted this issue into discussion #879 May 24, 2024
@github-project-automation github-project-automation bot moved this from Help Wanted to Done in Torrust Solution May 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Needs Feedback What dose the Community Think?
Projects
Status: Done
Development

No branches or pull requests

3 participants