use of com.hubspot.singularity.SingularityWebhook in project Singularity by HubSpot.
the class WebhookManager method requestHistoryEvent.
// TODO consider caching the list of hooks (at the expense of needing to refresh the cache and not
// immediately make some webhooks)
@Override
public void requestHistoryEvent(SingularityRequestHistory requestUpdate) {
for (SingularityWebhook webhook : getActiveWebhooksByType(WebhookType.REQUEST)) {
final String enqueuePath = getEnqueuePathForRequestUpdate(webhook.getId(), requestUpdate);
save(enqueuePath, requestUpdate, requestHistoryTranscoder);
}
}
use of com.hubspot.singularity.SingularityWebhook in project Singularity by HubSpot.
the class WebhookManager method deployHistoryEvent.
@Override
public void deployHistoryEvent(SingularityDeployUpdate deployUpdate) {
for (SingularityWebhook webhook : getActiveWebhooksByType(WebhookType.DEPLOY)) {
final String enqueuePath = getEnqueuePathForDeployUpdate(webhook.getId(), deployUpdate);
save(enqueuePath, deployUpdate, deployWebhookTranscoder);
}
}
use of com.hubspot.singularity.SingularityWebhook in project Singularity by HubSpot.
the class WebhookManager method taskHistoryUpdateEvent.
@Override
public void taskHistoryUpdateEvent(SingularityTaskHistoryUpdate taskUpdate) {
for (SingularityWebhook webhook : getActiveWebhooksByType(WebhookType.TASK)) {
final String enqueuePath = getEnqueuePathForTaskUpdate(webhook.getId(), taskUpdate);
save(enqueuePath, taskUpdate, taskHistoryUpdateTranscoder);
}
}
use of com.hubspot.singularity.SingularityWebhook in project Singularity by HubSpot.
the class SingularityWebhookSender method checkWebhooks.
public void checkWebhooks() {
final long start = System.currentTimeMillis();
final List<SingularityWebhook> webhooks = webhookManager.getActiveWebhooks();
if (webhooks.isEmpty()) {
return;
}
int taskUpdates = 0;
int requestUpdates = 0;
int deployUpdates = 0;
List<CompletableFuture<Response>> webhookFutures = new ArrayList<>();
for (SingularityWebhook webhook : webhooks) {
switch(webhook.getType()) {
case TASK:
taskUpdates += checkTaskUpdates(webhook, webhookFutures);
break;
case REQUEST:
requestUpdates += checkRequestUpdates(webhook, webhookFutures);
break;
case DEPLOY:
deployUpdates += checkDeployUpdates(webhook, webhookFutures);
break;
default:
break;
}
}
CompletableFutures.allOf(webhookFutures).exceptionally((t) -> {
LOG.error("Exception in webhook", t);
return null;
});
LOG.info("Sent {} task, {} request, and {} deploy updates for {} webhooks in {}", taskUpdates, requestUpdates, deployUpdates, webhooks.size(), JavaUtils.duration(start));
}
Aggregations