Improve workers for backtests
This commit is contained in:
@@ -62,6 +62,24 @@ public interface IJobRepository
|
||||
/// </summary>
|
||||
Task<IEnumerable<Job>> GetByGeneticRequestIdAsync(string geneticRequestId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets running job counts per user for a specific job type across all workers (global limit per user)
|
||||
/// </summary>
|
||||
/// <param name="workerId">The ID of the worker (kept for interface compatibility, not used for filtering)</param>
|
||||
/// <param name="jobType">The job type to filter by</param>
|
||||
/// <returns>Dictionary mapping UserId to count of running jobs</returns>
|
||||
Task<Dictionary<int, int>> GetRunningJobCountsByUserIdAsync(string workerId, JobType jobType);
|
||||
|
||||
/// <summary>
|
||||
/// Claims a random available job, atomically excluding users that have reached their capacity.
|
||||
/// The capacity check happens within the SQL query using a subquery, ensuring thread-safety across multiple workers.
|
||||
/// Returns null if no jobs are available.
|
||||
/// </summary>
|
||||
/// <param name="workerId">The ID of the worker claiming the job</param>
|
||||
/// <param name="jobType">The job type to claim</param>
|
||||
/// <param name="maxConcurrentPerUser">Maximum concurrent jobs allowed per user</param>
|
||||
Task<Job?> ClaimRandomJobAsync(string workerId, JobType jobType, int maxConcurrentPerUser);
|
||||
|
||||
/// <summary>
|
||||
/// Gets paginated jobs with optional filters and sorting
|
||||
/// </summary>
|
||||
@@ -91,6 +109,12 @@ public interface IJobRepository
|
||||
/// </summary>
|
||||
/// <returns>Summary containing counts by status, job type, and their combinations</returns>
|
||||
Task<JobSummary> GetSummaryAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a job by its ID
|
||||
/// </summary>
|
||||
/// <param name="jobId">The job ID to delete</param>
|
||||
Task DeleteAsync(Guid jobId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user