package com.atlassian.stash.internal.maintenance;

import com.atlassian.stash.internal.maintenance.latch.LatchState;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Represents the current state of Stash's maintenance system.
 */
public interface MaintenanceStatus {
    /**
     * If maintenance is in progress, retrieves the current {@link MaintenanceTaskStatus task} which can be used to
     * track its status. If maintenance is not in progress, retrieves the most-recently run
     * {@link MaintenanceTaskStatus task} if any.
     *
     * @return task for the in-progress maintenance else the most-recently run maintenance else {@code null} if no
     * maintenance has been run
     * @see MaintenanceService#start(MaintenanceTask, MaintenanceType)
     */
    @Nullable
    MaintenanceTaskStatus getLatestTask();

    /**
     * @return the current state of the SCM with respect to maintenance
     */
    @Nonnull
    LatchState getScmState();

    /**
     * @return the current state of the database with respect to maintenance
     */
    @Nonnull
    LatchState getDatabaseState();
}
