package com.atlassian.bitbucket.mesh.git.hook.script;

import org.springframework.scheduling.annotation.Scheduled;

/**
 * Schedules garbage collection for hook scripts.
 *
 * @since 1.4.2
 */
public class HookScriptGarbageCollectionScheduler {

    private final DefaultHookScriptManager hookScriptManager;

    public HookScriptGarbageCollectionScheduler(HookScriptManager hookScriptManager) {
        this.hookScriptManager = (DefaultHookScriptManager) hookScriptManager;
    }

    @Scheduled(fixedRateString = "${hookscripts.gc.raw-interval}", initialDelayString = "${hookscripts.gc.raw-delay}")
    public void schedule() {
        hookScriptManager.collectGarbage();
    }
}
