import { SYNC_TASK_EXECUTE, SYNC_TASK_START, SYNC_TASK_STOP } from '../logger/constants';
import { ILogger } from '../logger/types';
import { ISyncTask } from './types';
/**
* Creates an object that handles the periodic execution of a given task via "start" and "stop" methods.
* The task can be also executed by calling the "execute" method. Multiple calls run sequentially to avoid race conditions (e.g., submitters executed on SDK destroy or full queue, while periodic execution is pending).
*
* @param log - Logger instance.
* @param task - Task to execute that returns a promise that NEVER REJECTS. Otherwise, periodic execution can result in Unhandled Promise Rejections.
* @param period - Period in milliseconds to execute the task.
* @param taskName - Optional task name for logging.
* @returns A sync task that wraps the given task.
*/
export function syncTaskFactory(log: ILogger, task: (...args: Input) => Promise