use of com.hubspot.singularity.SingularityTaskWebhook in project Singularity by HubSpot.
the class SingularityWebhookSender method checkTaskUpdates.
private int checkTaskUpdates(SingularityWebhook webhook, List<CompletableFuture<Response>> webhookFutures) {
final List<SingularityTaskHistoryUpdate> taskUpdates = webhookManager.getQueuedTaskUpdatesForHook(webhook.getId());
int numTaskUpdates = 0;
for (SingularityTaskHistoryUpdate taskUpdate : taskUpdates) {
Optional<SingularityTask> task = taskHistoryHelper.getTask(taskUpdate.getTaskId());
// TODO compress
if (!task.isPresent()) {
LOG.warn("Couldn't find task for taskUpdate {}", taskUpdate);
webhookManager.deleteTaskUpdate(webhook, taskUpdate);
continue;
}
webhookFutures.add(webhookSemaphore.call(() -> executeWebhookAsync(webhook, new SingularityTaskWebhook(task.get(), taskUpdate), new SingularityTaskWebhookAsyncHandler(webhookManager, webhook, taskUpdate, shouldDeleteUpdateOnFailure(numTaskUpdates, taskUpdate.getTimestamp())))));
}
return taskUpdates.size();
}
Aggregations