package cn.superdesk.uniorder.common.queue.block;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class _TestCall {

	public static void main(String[] args) {


//		TaskInterface task = new XXXTask("DEFAULT-" + DateUtil.now()).setDuration(0).setPriority(TaskPriorityEnum.DEFAULT);
//		task.enqueue();
//		task.doTask();
//		task.finishTask();

//		TaskScheduler.getInstance().enqueue(new _TestTask("DEFAULT-" + DateUtil.now()).setDuration(0).setPriority(TaskPriorityEnum.DEFAULT));
//		TaskScheduler.getInstance().enqueue(new _TestTask("LOW-" + DateUtil.now()).setDuration(0).setPriority(TaskPriorityEnum.LOW));
//		TaskScheduler.getInstance().enqueue(new _TestTask("HIGH-" + DateUtil.now()).setDuration(0).setPriority(TaskPriorityEnum.HIGH));


		for (int i = 0; i < 1000; i++) {
			int taskPriority = RandomUtil.randomInt(0, 3);

			TaskScheduler.getInstance().enqueue(new _TestTask(StrUtil.format("#{}-{}#", TaskPriorityEnum.get(taskPriority).getDesc(), DateUtil.now()))
					.setDuration(0)
					.setPriority(TaskPriorityEnum.get(taskPriority))
			);
		}
	}
}