package com.atlassian.stash.internal.integrity;

import javax.annotation.Nonnull;
import java.util.List;

/**
 * @since 4.8
 */
public interface IntegrityCheckReporter {

    /**
     * Acknowledge that the integrity check report has been seen.
     */
    void acknowledge();

    /**
     * Logs an error message related to Integrity Checks.
     * Does <strong>not</strong> imply an inconsistency was found.
     *
     * @param message message template
     * @param objects message template parameters
     */
    void error(@Nonnull String message, @Nonnull Object... objects);

    /**
     * Report that integrity checking has completed.
     */
    void markChecksComplete();

    /**
     * Check if integrity checking has already been started by another node <em>in the current cluster</em>.
     * If integrity checking has never been started, or if integrity checking was started but the cluster node that
     * started it is no longer a member of the current cluster, report that integrity checking has started and return
     * {@code true}. But if integrity checking was already started by a cluster node that's still a member of the
     * current cluster, then do nothing and return {@code false}.
     *
     * @return {@code true} if integrity checks were successfully started, or {@code false} otherwise
     */
    boolean markChecksStarted();

    /**
     * Logs a debug message related to Integrity Checks.
     * Does <strong>not</strong> imply an inconsistency was found.
     *
     * @param message message template
     * @param objects message template parameters
     */
    void debug(@Nonnull String message, @Nonnull Object... objects);

    /**
     * @return a list of the latest {@code limit} {@link IntegrityEventKey event keys}
     */
    @Nonnull
    List<IntegrityEventKey> getLatestEvents(int limit);

    /**
     * Logs an informational message related to Integrity Checks.
     * Does <strong>not</strong> imply an inconsistency was found.
     *
     * @param message message template
     * @param objects message template parameters
     */
    void info(@Nonnull String message, @Nonnull Object... objects);

    /**
     * Report an inconsistency found by an integrity checking process. In the context of integrity checking an
     * inconsistency means a discrepancy between the filesystem and the database.
     *
     * @param message message template
     * @param objects message template parameters
     */
    void reportInconsistency(@Nonnull String message, @Nonnull Object... objects);

    /**
     * Logs a warning message related to Integrity Checks.
     * Does <strong>not</strong> imply an inconsistency was found.
     *
     * @param message message template
     * @param objects message template parameters
     */
    void warn(@Nonnull String message, @Nonnull Object... objects);
}
