package com.atlassian.stash.internal.maintenance;

import javax.annotation.Nonnull;

/**
 * A helper for locking and unlocking the system using a provided {@link JohnsonMaintenanceEvent}. The primary goal of this
 * helper is to allow locking to have different strategies which can be applied as necessary.
 * <p>
 * When used in a cluster, this helper will lock the <i>entire cluster</i>, not just the local node.
 *
 * @since 3.0
 */
public interface MaintenanceModeHelper {

    /**
     * Locks the system, using the provided event as a key.
     *
     * @param event the key event
     */
    void lock(@Nonnull JohnsonMaintenanceEvent event);

    /**
     * Unlocks the system <i>if it is locked using the provided event</i>. If another event was used to lock the
     * system, it will not be unlocked.
     *
     * @param event the key event
     */
    void unlock(@Nonnull JohnsonMaintenanceEvent event);
}
