package io.openems.common.bridge.http.api;

import java.util.Map;
import java.util.concurrent.ScheduledFuture;

import io.openems.common.bridge.http.time.DelayTimeProvider;

/**
 * Executor to handle tasks created by a {@link BridgeHttp}.
 */
public interface BridgeHttpExecutor {

	/**
	 * Schedules a task to be executed from now plus the given delay.
	 * 
	 * @param task          the task to execute
	 * @param durationDelay the delay to schedule toe task
	 * @return a {@link ScheduledFuture}
	 */
	ScheduledFuture<?> schedule(Runnable task, DelayTimeProvider.Delay.DurationDelay durationDelay);

	/**
	 * Executes the given task.
	 * 
	 * @param task the task to execute
	 */
	void execute(Runnable task);

	/**
	 * Determines if this executor is shutdown.
	 * 
	 * @return true if this executor is shutdown else false
	 */
	boolean isShutdown();

	/**
	 * Returns key metrics of this executor.
	 * 
	 * @return a map with key metrics
	 */
	Map<String, Long> getMetrics();

	/**
	 * Sets the maximum pool size of this executor.
	 *
	 * @param maximumPoolSize the maximum pool size
	 */
	void setMaximumPoolSize(int maximumPoolSize);

}
