com.hubspot.singularity.smtp.NoopMailer Maven / Gradle / Ivy
package com.hubspot.singularity.smtp;
import com.hubspot.singularity.ExtendedTaskState;
import com.hubspot.singularity.SingularityDisastersData;
import com.hubspot.singularity.SingularityRequest;
import com.hubspot.singularity.SingularityTask;
import com.hubspot.singularity.SingularityTaskHistory;
import com.hubspot.singularity.SingularityTaskId;
import com.hubspot.singularity.api.SingularityPauseRequest;
import com.hubspot.singularity.api.SingularityScaleRequest;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NoopMailer implements SingularityMailer {
private static final Logger LOG = LoggerFactory.getLogger(NoopMailer.class);
private static final NoopMailer INSTANCE = new NoopMailer();
private NoopMailer() {}
public static NoopMailer getInstance() {
return INSTANCE;
}
@Override
public void sendTaskOverdueMail(
Optional task,
SingularityTaskId taskId,
SingularityRequest request,
long runTime,
long expectedRuntime
) {
logNotSendingEmail("task overdue");
}
@Override
public void queueTaskCompletedMail(
Optional task,
SingularityTaskId taskId,
SingularityRequest request,
ExtendedTaskState taskState
) {
logNotSendingEmail("task completed");
}
@Override
public void sendTaskCompletedMail(
SingularityTaskHistory taskHistory,
SingularityRequest request
) {
logNotSendingEmail("task completed");
}
@Override
public void sendRequestPausedMail(
SingularityRequest request,
Optional pauseRequest,
Optional user
) {
logNotSendingEmail("request paused");
}
@Override
public void sendRequestUnpausedMail(
SingularityRequest request,
Optional user,
Optional message
) {
logNotSendingEmail("request unpaused");
}
@Override
public void sendRequestScaledMail(
SingularityRequest request,
Optional newScaleRequest,
Optional formerInstances,
Optional user
) {
logNotSendingEmail("request scaled");
}
@Override
public void sendRequestRemovedMail(
SingularityRequest request,
Optional user,
Optional message
) {
logNotSendingEmail("request removed");
}
@Override
public void sendRequestInCooldownMail(SingularityRequest request) {
logNotSendingEmail("request in cooldown");
}
private void logNotSendingEmail(String type) {
LOG.debug("Not sending " + type + " mail - no SMTP configuration is present");
}
@Override
public void sendDisasterMail(final SingularityDisastersData disastersData) {
logNotSendingEmail("new disaster");
}
}