Skip to content
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

Extract Tracker API Client packages #689

Open
josecelano opened this issue Feb 9, 2024 · 0 comments
Open

Extract Tracker API Client packages #689

josecelano opened this issue Feb 9, 2024 · 0 comments
Labels
Code Cleanup / Refactoring Tidying and Making Neat
Milestone

Comments

@josecelano
Copy link
Member

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: #255 (comment)

@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label Feb 9, 2024
@josecelano josecelano self-assigned this Feb 9, 2024
josecelano added a commit to torrust/torrust-index that referenced this issue Feb 12, 2024
3f629c2 refactor: [#473] tracker API client. Remove duplicate code (Jose Celano)
7256b46 feat: [#473] add timeout to Tracker API Client requests (Jose Celano)

Pull request description:

  Ass default timeout of 5 seconds for Tracker API requests.

  In the future, we could use the official Tracker API client. See torrust/torrust-tracker#689.

  However, it's also fine to use this reduced client. Because we do not need all the PAI endpoints.

ACKs for top commit:
  josecelano:
    ACK 3f629c2

Tree-SHA512: fc22ceac6ef234fb1bd20b6ae5099cea17ddfe2cb599faa3ad6f3e2ae04d93043e6af0b9a85dc41785f0a99bf7ace13f8e5e0cb656058390bf20585b236bf5e6
@cgbosse cgbosse added this to the v3.1.0 milestone May 24, 2024
@josecelano josecelano removed their assignment Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat
Projects
Status: No status
Development

No branches or pull requests

2 participants