How jwcjlu/dragonfly2 works
Main Components
• Manager:
• Responsible for cluster management, dynamic configuration, and RBAC.
• Includes a front-end console for visual oversight.
• Relevant directories: “manager”, “manager/handlers”, “manager/rpcserver”, “manager/config”, “manager/database”, and “manager/router”.
• Scheduler:
• Handles selecting the optimal parent peer for content distribution,
including evaluating network topology and resource availability.
• Relevant directories: “scheduler”, “scheduler/scheduling”, “scheduler/resource”, “scheduler/rpcserver”, “scheduler/config”.
• Seed Peer:
• Acts as the primary “back-to-source” download peer in the P2P cluster.
• This is integrated into the dfdaemon when operated in Seed Peer mode.
• Peer:
• Represents the client side running the “dfdaemon” and “dfget” command-line tool.
• Includes functionalities for file download and communication with other peers.
• Relevant directories: “client” (with various subdirectories such as “daemon”, “dfget”, “dfstore”), “cmd/dfget”, “cmd/dfcache”, “cmd/dfstore”.
• Additional components:
• Trainer: Found under “trainer” (used for training, perhaps around performance or data handling).
• API layer: The “api” directory indicates an HTTP API layer (with Swagger files available) for external communication.
• Plugin support and core libraries: The “pkg” and “internal” directories contain the underlying libraries, plugins, and common utilities.
Out the Relationships and Interactions
• The Manager interacts with the Scheduler via APIs (or RPC interfaces) to maintain cluster state, schedule download tasks, and handle configuration changes.
• Peers (running dfdaemon and dfget) communicate with each other for P2P file distribution. They can request downloads via the Scheduler and may fall back on Seed Peer mode if needed.
• The API layer (in “api”) serves external or administrative calls to the Manager.
• There’s communication between the Manager, Scheduler, and even Trainer components through established RPC protocols. Look for directories like “pkg/rpc” and “manager/rpcserver” which encapsulate these interactions.
• Internal libraries (under “internal” and “pkg”) support fundamental patterns such as caching, logging, networking, and security which are used across all main components.
Architectural Patterns and Technologies
• Distributed P2P architecture: Emphasize the use of peer-to-peer interactions for file distribution.
• Client-Server and RPC-based microservices: Manager, Scheduler, and Peer components interact over defined APIs/RPC servers (multiple “client” folders under “pkg/rpc”).
• Containerized deployment: Notice the “build/images”, “deploy/docker-compose”, and “deploy/helm-charts” directories which show container/Docker and Kubernetes deployment support.
• CI/CD Pipeline: The .github/workflows directory and other build scripts reflect integration and release automation.
• Security aspects such as RBAC (in Manager), TLS, and audit reports (linked in the README).