Skip to content

Overhaul stats: Consider renaming package torrent-repository to swarm-repository #1519

@josecelano

Description

@josecelano

The main types in the torrent-repository package are:

  • Swarm
  • Swarms

Proposal 1

  • Rename folder torrent-repository to swarms
  • Rename crate from torrust-tracker-torrent-repository to torrust-tracker-swarms
  • Rename type Swarms to SwarmRepository

I'm not sure about using "repository" because I usually use "repository" for just storing/retrieving things, and these types have more responsibilities.

cc @da2ce7


Package summary with AI model

  • Model: GPT4-o

The torrent-repository package appears to be a workspace package responsible for managing torrent entries and their associated peer lists in memory. It provides a high-performance in-memory data structure for handling torrent-related operations. Here's a summary:

Summary:

  • Purpose:
    The package is used to manage torrent entries and their associated peer lists in memory. It acts as a repository for torrent data, enabling operations like adding, updating, querying, and removing torrent entries and peers.

  • Responsibilities:

    • Storing and managing torrent entries and their associated peer lists.
    • Handling operations like inserting/updating peers, removing inactive peers, and removing torrents without active peers.
    • Providing methods to retrieve torrent metadata, peer lists, and aggregate metrics.
    • Importing persistent torrent data into the in-memory repository.
    • Supporting pagination for querying torrent entries.

Responsibilities of Swarm and Swarms Types

Swarm

The Swarm type represents a collection of peers associated with a single torrent. Its responsibilities include:

  1. Peer Management:

    • Adding, updating, and removing peers.
    • Maintaining a list of active peers and their metadata.
    • Handling peer-specific events, such as when a peer completes a download or becomes inactive.
  2. Metadata Management:

    • Storing and updating metadata about the swarm, such as the number of seeders, leechers, and completed downloads.
  3. Event Handling:

    • Triggering events when peers are added, updated, or removed.
    • Sending notifications for significant changes in the swarm's state.
  4. Policy Enforcement:

    • Applying tracker policies, such as removing inactive peers or torrents without active peers.
Swarms

The Swarms type acts as a repository for multiple Swarm instances, each representing a torrent. Its responsibilities include:

  1. Torrent Management:

    • Adding, updating, and removing torrents.
    • Importing persistent torrent data into memory.
  2. Aggregate Operations:

    • Calculating aggregate metrics across all torrents, such as the total number of seeders, leechers, and torrents.
    • Counting peerless torrents and removing them based on tracker policies.
  3. Pagination and Querying:

    • Providing paginated access to torrent entries.
    • Retrieving metadata and peer lists for specific torrents.
  4. Event Propagation:

    • Broadcasting events related to torrents and their swarms.

Summary

  • Swarm focuses on managing peers and metadata for a single torrent.
  • Swarms manages multiple Swarm instances and provides higher-level operations and aggregate metrics.

Proposed Alternative Names focused on the repo aspect

  1. torrent-memory-repository
  2. in-memory-torrent-store
  3. torrent-data-manager
  4. torrent-swarm-repository
  5. torrent-repository-core
  6. swarm-repository

Suggested Alternative Names

Given that the Swarm and Swarms types have responsibilities beyond simple storage and retrieval, such as managing peers, enforcing policies, and handling events, a name that reflects these broader responsibilities would be more appropriate.

  1. torrent-swarm-manager: Highlights the management aspect of torrents and their swarms.
  2. torrent-swarm-coordinator: Emphasizes coordination of peers and torrents.
  3. torrent-swarm-registry: Suggests a registry-like structure for managing torrents and their peers.
  4. torrent-swarm-service: Indicates a service-oriented role for handling torrent-related operations.
  5. torrent-swarm-controller: Reflects control and oversight responsibilities.

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions