torrust-tracker icon indicating copy to clipboard operation
torrust-tracker copied to clipboard

Extract Tracker API Client packages

Open josecelano opened this issue 1 year ago • 0 comments

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

Relates to: https://github.com/torrust/torrust-tracker/issues/255#issuecomment-1477478212

josecelano avatar Feb 09 '24 09:02 josecelano