Skip to content

Refactor: extract type ServiceBinding #1422

Description

@josecelano

In this PR:

I added a new field to the health check API endpoint listen_url:

{
  "status": "Ok",
  "message": "",
  "details": [
    {
      "listen_url": "http://0.0.0.0:7070/",
      "binding": "0.0.0.0:7070",
      "service_type": "http_tracker",
      "info": "checking http tracker health check at: http://0.0.0.0:7070/health_check",
      "result": {
        "Ok": "200 OK"
      }
    }
  ]
}

I used a Url type but I have decided to introduce a new type, because it's a URL with some restrictions and actually it also allows some invalid URLs.

The idea of the ype is to represent the same thing as the "binding" socket address but including information about the URL: protocol and path.

I will use this new type in the ServiceHealthCheckJob:

pub struct ServiceHealthCheckJob {
    pub listen_url: Url,
    pub binding: SocketAddr,
    pub info: String,
    pub service_type: String,
    pub job: JoinHandle<ServiceHeathCheckResult>,
}

I will also rename the field in the health check API endpoint.

I will also use this new type in other places where we need the protocol in addition to the bind address. Like for example in this issue:

#1415

cc @da2ce7

Metadata

Metadata

Assignees

Labels

- Developer -Torrust Improvement Experience

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions