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

Refactor packages: review UDP events #1319

Closed
josecelano opened this issue Feb 24, 2025 · 1 comment · Fixed by #1328
Closed

Refactor packages: review UDP events #1319

josecelano opened this issue Feb 24, 2025 · 1 comment · Fixed by #1328
Assignees
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Comments

@josecelano
Copy link
Member

These are the events used for statistics:

HTTP core (http-tracker-core)

- Tcp4Announce  Tcp6Announce
- Tcp4Scrape    Tcp6Scrape
UDP core (udp-tracker-core)

- Udp4Announce  Udp6Announce
- Udp4Scrape    Udp6Scrape
- Udp4Connect   Udp6Connect

- Udp4Request   Udp6Request
- Udp4Response  Udp6Response

- Udp4Error     Udp6Error
- UdpRequestAborted
- UdpRequestBanned

And this is where those events are used::

HTTP core (http-tracker-core)

- Tcp4Announce  Tcp6Announce
- Tcp4Scrape    Tcp6Scrape
UDP core (udp-tracker-core)

- Udp4Announce  Udp6Announce
- Udp4Scrape    Udp6Scrape
- Udp4Connect   Udp6Connect

UDP server (udp-tracker-server)

- Udp4Request   Udp6Request
- Udp4Response  Udp6Response

- UdpRequestAborted
- UdpRequestBanned,

- Udp4Error     Udp6Error

Maybe we should split UDP events into:

  • UDP tracker core events
  • UDP tracker server events

UDP tracker core events would be the same as in the HTTP tracker core and the extra connect events that doesn't exist in the HTTP tracker.

For me those events are produced at different layers and it does not make sense to add events to the UDP tracker code that only make sense for the UDP server.

My proposal is to split them and move the UDP server events to the UDP server package (udp-tracker-server).

If we want to keep them in the UDP tracker core we should find the way to send them at the core level. For example, there is an special case, the Udp4Error and Udp6Error errors are sent when the server sends an error response. We could send them when the tracker core returns an error from the announce and scrape requests. However that would change a little bit the meaning of the event:

  • Udp4Error and Udp6Error sent in the UDP tracker core: a request produced an error.
  • Udp4Error and Udp6Error sent in the UDP tracker server: the server sent a response error.

Since we don't have events in the HTTP tracker core for this case I would keep those errors in the server for now.

I will not change drastically events in this issue. I just one to move events to the right layers (package), however I think we need to make a big refactor. For example, for the HTTP tracker:

pub enum Event {
    Tcp4Announce,
    Tcp4Scrape,
    Tcp6Announce,
    Tcp6Scrape,
}

I would do this:

pub enum Event {
    TcpAnnounce { scheme: HTTPorUDP, ip_version: V4orV6 },
    TcpScrape { scheme: HTTPorUDP, ip_version: V4orV6 },
}

That is out of the scope of this issue.

cc @da2ce7

@josecelano josecelano added - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat labels Feb 24, 2025
@josecelano josecelano self-assigned this Feb 24, 2025
@josecelano
Copy link
Member Author

josecelano commented Feb 26, 2025

I will not change drastically events in this issue. I just one to move events to the right layers (package), however I think we need to make a big refactor. For example, for the HTTP tracker:

pub enum Event {
Tcp4Announce,
Tcp4Scrape,
Tcp6Announce,
Tcp6Scrape,
}
I would do this:

pub enum Event {
TcpAnnounce { scheme: HTTPorUDP, ip_version: V4orV6 },
TcpScrape { scheme: HTTPorUDP, ip_version: V4orV6 },
}
That is out of the scope of this issue.

cc @da2ce7

I have described this change in a new issue: #1327

josecelano added a commit to josecelano/torrust-tracker that referenced this issue Feb 26, 2025
We will splot UDP stats events into:

- UDP core events
- UDP server event

This is step 1 in the refactor:

- Step 1. Create UDP server events.
- Step 2. Remove UDP server events from core events.
@josecelano josecelano linked a pull request Feb 26, 2025 that will close this issue
2 tasks
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Feb 26, 2025
…re package

Some events were moved from the `udp-tracker-core` package to the
`udp-tracker-server` package.

This commits remmoves the unused events from the `udp-tracker-core`.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Feb 26, 2025
…re package

Some events were moved from the `udp-tracker-core` package to the
`udp-tracker-server` package.

This commits remmoves the unused events from the `udp-tracker-core`.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Feb 26, 2025
…re package

Some events were moved from the `udp-tracker-core` package to the
`udp-tracker-server` package.

This commits remmoves the unused events from the `udp-tracker-core`.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Feb 26, 2025
…re package

Some events were moved from the `udp-tracker-core` package to the
`udp-tracker-server` package.

This commits remmoves the unused events from the `udp-tracker-core`.
josecelano added a commit that referenced this issue Feb 26, 2025
b8d2f76 refactor: [#1319] remove UDP server events from UDP tracker core package (Jose Celano)
3f55b9d refactor: [#1319] add UDP server events (Jose Celano)

Pull request description:

  This splits the UDP stats events into two different types of events (one for each layer):

  - UDP core events
  - UDP server event

  ### Subtasks

  - [x] Step 1. Create UDP server events.
  - [x] Step 2. Remove UDP server events from core events.

ACKs for top commit:
  josecelano:
    ACK b8d2f76

Tree-SHA512: f37b8e1a1cb577122316d85b68372e47c3274347666ce48eb19e3c7f776128b560c693412ed16dc4f44cca6557256e05e10fcce7654ca8d451d167126360dcae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant