callbackWithToken calls the callback with the appropriate entity/subject ID and continuous token. This method retrieves the correct request from the sorted list and generates the appropriate continuous token for pagination support. Parameters: - index: The index of the result in the sorted list
(index int)
| 434 | // Parameters: |
| 435 | // - index: The index of the result in the sorted list |
| 436 | func (bc *BulkChecker) callbackWithToken(index int) { |
| 437 | requests := bc.getSortedRequests() |
| 438 | |
| 439 | // Validate index bounds |
| 440 | if index >= len(requests) { |
| 441 | return |
| 442 | } |
| 443 | |
| 444 | var id string |
| 445 | var ct string |
| 446 | |
| 447 | // Extract ID and generate continuous token based on checker type |
| 448 | switch bc.typ { |
| 449 | case BulkCheckerTypeEntity: |
| 450 | id = requests[index].Request.GetEntity().GetId() |
| 451 | if index+1 < len(requests) { |
| 452 | ct = utils.NewContinuousToken(requests[index+1].Request.GetEntity().GetId()).Encode().String() |
| 453 | } |
| 454 | case BulkCheckerTypeSubject: |
| 455 | id = requests[index].Request.GetSubject().GetId() |
| 456 | if index+1 < len(requests) { |
| 457 | ct = utils.NewContinuousToken(requests[index+1].Request.GetSubject().GetId()).Encode().String() |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | // Call the user-provided callback |
| 462 | bc.callback(id, ct) |
| 463 | } |
| 464 | |
| 465 | // Close properly cleans up resources and cancels all operations. |
| 466 | // This method should be called when the BulkChecker is no longer needed |
no test coverage detected