andrade-soulseek-downloader
Version:
Simple, safe Soulseek download library with built-in rate limiting to prevent bans
40 lines • 1.58 kB
TypeScript
import { Track } from '../entities';
import { ILogger } from '../../shared';
/**
* Service for managing concurrent download racing.
* Implements intelligent parallel downloading with automatic cancellation.
*/
export declare class DownloadRacingService {
private logger;
constructor(logger: ILogger);
/**
* Groups tracks by equivalent quality for racing.
* @param tracks - Sorted tracks (best quality first)
* @param maxConcurrent - Maximum concurrent downloads per race
* @returns Groups of tracks for racing
*/
groupTracksForRacing(tracks: Track[], maxConcurrent?: number): Track[][];
/**
* Races multiple downloads and returns the first successful one.
* @param tracks - Tracks to race (should be from same quality group)
* @param downloadFn - Function to download a single track
* @returns Promise that resolves with first successful download
*/
raceDownloads<T>(tracks: Track[], downloadFn: (track: Track) => Promise<T | null>): Promise<{
result: T;
winner: Track;
} | null>;
/**
* Selects best tracks for racing, ensuring diversity of users.
* @param tracks - All available tracks
* @param maxPerRace - Maximum tracks per race
* @returns Tracks optimized for racing
*/
selectTracksForRacing(tracks: Track[], maxPerRace?: number): Track[];
/**
* Logs racing strategy information.
* @param groups - Track groups for racing
*/
logRacingStrategy(groups: Track[][]): void;
}
//# sourceMappingURL=download-racing-service.d.ts.map