Alternatives to the Tracker REST API #1307
Replies: 4 comments
-
AI Research Prompt
|
Beta Was this translation helpful? Give feedback.
-
AI R1 (Friendli) responseOkay, the user wants me to review their draft comment for starting a discussion on GitHub about building a new API for their Rust-based Bittorrent Tracker. Let me read through it carefully to understand the context and their proposals. First, the context: They have a REST API with four main areas: stats, torrents, whitelist, and authentication keys. They're discussing two proposals: moving to GraphQL or emitting events from the core tracker. The user has broken down the responsibilities into queries and commands, mentioned CQRS, and outlined pros and cons of each approach. Now, I need to check the clarity and structure of the draft. Are the key points presented effectively? Is there any confusion between the proposals? Let's see. The user starts by summarizing the meeting and context, which is good for readers who might not have been there. They explain the current REST API and its components. Then they present Proposal 1 (GraphQL) and Proposal 2 (event emission). The explanation of separating queries and commands using CQRS is clear, and the note about scalability issues with an example from their repo adds context. Possible improvements: Maybe clarify how GraphQL and event-driven approaches can coexist. The user mentions that events are for 20% demanding cases, so emphasizing that these are complementary solutions might help. Also, the plan at the end could be formatted more clearly as action items or questions for the team. Structure-wise, using bullet points and sections makes it readable. However, the sections could be marked more distinctly, like using headers for each proposal. Also, hyperlinking the references (like the CQRS article) is helpful. The "pros and cons" are listed, but maybe numbered lists would make them stand out more. The user’s plan is to reflect on integration needs, decide on one or two APIs, and consider alternatives. They should maybe pose these steps as specific questions to the team to invite discussion. For example, asking which approach the team prefers, or if there are other alternatives. Grammar and typos: "folowiing" in the initial message is a typo, but in the draft itself, it's okay. The phrase "It's the folowiing:" should be corrected in the user's query, but in the draft, the content seems fine. Also, the user mentions @da2ce7's suggestions, which is good for attribution. However, ensuring all contributors are mentioned if they contributed ideas might be necessary. In terms of technical accuracy: The user correctly differentiates between queries and commands, and the event-driven approach for real-time data needs. Pointing out the scalability issue with the current REST API and how events can offload that makes sense. Suggested additions: Perhaps flowchart diagrams or examples of how each API would handle a sample request could help, but maybe that's too detailed for a discussion starter. Alternatively, posing open-ended questions to the team about their preferences, use cases, or potential pitfalls they foresee could foster more engagement. Overall, the draft is well-structured and informative. Adding explicit questions to the team and slightly enhancing the formatting could make it more effective in prompting discussion. Your draft is thorough and well-structured, but here are some suggestions to improve clarity, engagement, and decision-making: Suggested Edits/Improvements:1. Add a Clear Purpose & Call-to-ActionStart with a concise goal and direct ask to encourage participation:
2. Reorganize Proposals for ComparisonUse a table or bulleted list to contrast GraphQL vs. Events (or highlight complementary roles). For example:
3. Clarify Complementary RolesExplicitly state how they could coexist:
4. Pose Specific QuestionsGuide the discussion with actionable prompts:
5. Simplify Technical JargonReplace niche terms (e.g., "projection") with plain language where possible to widen accessibility:
6. Highlight Risks 🔥Call out potential downsides to spark debate:
7. Link to Prior ArtReference similar projects/standards to anchor proposals:
8. Final Draft Structure
This structure invites focused feedback while ensuring technical depth. Would you like me to draft a full revised version? |
Beta Was this translation helpful? Give feedback.
-
R1 (prompt)
Here’s a concise summary of using GraphQL to unify command execution, application state queries, and real-time event subscriptions via Rust’s GraphQL as the Unified API Layer 🚀
Key Benefits
Implementation Steps
Caveats
Decision NeededShould we adopt this hybrid model? Let me know if you’d like to refine specific aspects! |
Beta Was this translation helpful? Give feedback.
-
In this week meeting @da2ce7 and I were discussing about this. I would highlight two points:
That means not only the Index would use it but potentially even bittorrent clients or other apps in the future.
Apparently there can be two ways of conceptualize the tracker events using GraphQL. The first one is:
For example,
The bittorrent client would be interested in events like "peer added", "peer removed" and the index client would be interested in events like "seeder added", "seeder removed", "leecher added", "leecher removed", "donwload completed" or something more generic like "swarn stats changed". The second one (although I don't know if it would be the same in the end):
I'm concern about this approach because we have been using only memory so far for the core data and we would have thousandths of events. Event if we ignore the announce requests at regular intervals the number of events in a subscriptions would be very high. In the torrust demo tracker we are receiving 2000 req/sec. I don't know how many of those request actually produce a mutation. I mean adding or removing a peer it's an interesting event you want to share with clients but a regular announce request it might not be. I'm also concern about how can we let the index, for example, subscribe only the events for the info-hashes the index has. With a public tracker the index is normally only interested in the its torrents. We might need to introduce a new concept like "torrent set" but that would imply the API clients need to provide to the server their sets. So the server has to store info about the clients. And I do not like that. Alternatively we can let the Index filter out torrents but that leads to the problem we have right now for public tracker. The Index has to pull info from one torrent at the time even if the info for those torrents hasn't changed. |
Beta Was this translation helpful? Give feedback.
-
Today in our weekly meeting we had an interesting conversation about the tracker integration with other system in terms of exporting data. I will try to summary the points and conclusions.
Context
The Tracker runs a REST API (if enabled) that allow interaction with other external systems.
In the current version 1 we have 4 different contexts:
Proposal 1: GraphQL API
@da2ce7 proposed starting considering a new implementation in GraphQL.
Proposal 2: Emit events from core tracker
I proposed to first research about our needs: what was the goal of creating the REST API?
The main reason was to provide an integration point with the Torrust Index. One of the goal is to export data from the Tracker to external systems, being our our Index implementation or other indexes. However @da2ce7 pointed out that that was not the only reason because the API also accepts commands. In fact, in the first version the tracker configuration could be changed from the Index.
I think we can segregate responsibilities of the REST API into two responsibilities:
See https://martinfowler.com/bliki/CQRS.html
NOTE: maybe we could have to separate APIs because their requirements could be different. The query responsibility could be much more complex if we want to provide complex stats to private indexes. See #820.
What I proposed was at least to consider other alternatives to export data, for example: emitting events.
If the tracker core emited 4 basis events:
It would be possible to any external system to build any projection of the data (no data loss).
External system like an Index could subscribe to the tracker events and build their own views in their preferred DB systems.
Of course, this proposal does not excluded the GraphQL proposal. As I see it the GraphQL solution could be good for 80% of consumers while the "events" approach could fit for the most demanding systems (the other 20%), demanding data that we don't store directly in the tracker).
In fact, the current REST API has some scalability problems. See torrust/torrust-index#569. And we are only importing basic stats. It would be impossible to generate and import peer-level stats with this solution.
I'm not proposing any concrete implementation, only the pattern: event emitter/event subscriber.
This can be implemented in may different ways. For example, @da2ce7 proposed using the crate
tracing
which is already installed. Consumers can parse the logs an extract the "domain" events they are interested in. There could even be different driver implementations to send events in different ways to external services.Pros:
Cons:
My plan would be:
Beta Was this translation helpful? Give feedback.
All reactions