processRequest handles a single request with comprehensive error handling. This method is executed in a separate goroutine for each request and: 1. Acquires a semaphore slot to control concurrency 2. Performs the permission check or uses pre-computed result 3. Processes the result in the correct ord
(ctx context.Context, sem *semaphore.Weighted, index int, req BulkCheckerRequest)
| 330 | // Returns: |
| 331 | // - error: Any error that occurred during processing |
| 332 | func (bc *BulkChecker) processRequest(ctx context.Context, sem *semaphore.Weighted, index int, req BulkCheckerRequest) error { |
| 333 | // Check context before acquiring semaphore |
| 334 | if err := ctx.Err(); err != nil { |
| 335 | return nil |
| 336 | } |
| 337 | |
| 338 | // Acquire semaphore slot to control concurrency |
| 339 | if err := sem.Acquire(ctx, 1); err != nil { |
| 340 | if isContextError(err) { |
| 341 | return nil |
| 342 | } |
| 343 | return fmt.Errorf("failed to acquire semaphore: %w", err) |
| 344 | } |
| 345 | defer sem.Release(1) |
| 346 | |
| 347 | // Determine the result for this request |
| 348 | result, err := bc.getRequestResult(ctx, req) |
| 349 | if err != nil { |
| 350 | if isContextError(err) { |
| 351 | return nil |
| 352 | } |
| 353 | return fmt.Errorf("failed to get request result: %w", err) |
| 354 | } |
| 355 | |
| 356 | // Process the result in the correct order |
| 357 | return bc.processResult(index, result) |
| 358 | } |
| 359 | |
| 360 | // getRequestResult determines the result for a request. |
| 361 | // This method either uses a pre-computed result if available, |
no test coverage detected