Skip to content

Extract Tracker API Client packages #689

@josecelano

Description

@josecelano

Relates to: torrust/torrust-index#806
Relates to: #255 (comment)

We are using a Tracker API Client in test code.

See: https://github.com/torrust/torrust-tracker/blob/develop/tests/servers/api/v1/client.rs

That client is duplicated in the Index because the Index calls the Tracker API:

https://github.com/torrust/torrust-index/blob/develop/src/tracker/api.rs

We should extract that login into an independent package so that the Index can use it and we remove that duplicate code.

Before extracting the package we should clean it and make it ready for production. Currently, is not ready because

  • The URL schema is hardcoded to http://.
  • It panics if the HTTP fails. We should return an error and let the user handle it.
  • We should decide if we expose request errors or we wrap them.

I propose to create this packages:

  • folder (crates.io package name)
  • packages/api-types (torrust-tracker-api-types)
  • packages/api-client (torrust-tracker-api-client) <- depends on torrust-tracker-api-types
  • packages/api-server (torrust-tracker-api-server) <- depends on torrust-tracker-api-types. Maybe in the future

IMPORTANT: the implementation in the Index was improved. We have to apply those improvements to this client.

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions