All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.extjobrunr.provider.Provider Maven / Gradle / Ivy

package com.github.lontime.extjobrunr.provider;

import java.time.Instant;
import java.time.ZoneId;
import java.util.UUID;
import java.util.stream.Stream;

import com.github.lontime.base.commonj.components.ComponentLifecycle;
import com.github.lontime.base.commonj.components.LazyComponent;
import org.jobrunr.jobs.JobId;
import org.jobrunr.jobs.lambdas.IocJobLambda;
import org.jobrunr.jobs.lambdas.IocJobLambdaFromStream;
import org.jobrunr.jobs.lambdas.JobLambda;
import org.jobrunr.jobs.lambdas.JobLambdaFromStream;
import org.jobrunr.scheduling.BackgroundJob;

/**
 * Provider.
 * @author lontime
 * @since 1.0
 */
public interface Provider extends AutoCloseable, ComponentLifecycle, LazyComponent {

    /**
     * enqueue.
     * @param job job
     * @return JobId
     */
    default JobId enqueue(JobLambda job) {
        return BackgroundJob.enqueue(job);
    }

    /**
     * enqueue.
     * @param job job
     * @param id id
     * @return JobId
     */
    default JobId enqueue(UUID id, JobLambda job) {
        return BackgroundJob.enqueue(id, job);
    }

    /**
     * enqueue.
     * @param input input
     * @param jobFromStream jobFromStream
     * @param  T
     */
    default  void enqueue(Stream input, JobLambdaFromStream jobFromStream) {
        BackgroundJob.enqueue(input, jobFromStream);
    }

    /**
     * enqueue.
     * @param iocJob iocJob
     * @param  S
     * @return JobId
     */
    default  JobId enqueue(IocJobLambda iocJob) {
        return BackgroundJob.enqueue(iocJob);
    }

    /**
     * enqueue.
     * @param id id
     * @param iocJob iocJob
     * @param  S
     * @return JobId
     */
    default  JobId enqueue(UUID id, IocJobLambda iocJob) {
        return BackgroundJob.enqueue(id, iocJob);
    }

    /**
     * enqueue.
     * @param input input
     * @param iocJobFromStream iocJobFromStream
     * @param  S S
     * @param  T T
     */
    default  void enqueue(Stream input, IocJobLambdaFromStream iocJobFromStream) {
        BackgroundJob.enqueue(input, iocJobFromStream);
    }

    /**
     * schedule.
     * @param instant instant
     * @param job job
     * @return JobId
     */
    default JobId schedule(Instant instant, JobLambda job) {
        return BackgroundJob.schedule(instant, job);
    }

    /**
     * schedule.
     * @param instant instant
     * @param job job
     * @param id id
     * @return JobId
     */
    default JobId schedule(UUID id, Instant instant, JobLambda job) {
        return BackgroundJob.schedule(id, instant, job);
    }

    /**
     * schedule.
     * @param instant instant
     * @param iocJob iocJob
     * @param  S
     * @return JobId
     */
    default  JobId schedule(Instant instant, IocJobLambda iocJob) {
        return BackgroundJob.schedule(instant, iocJob);
    }

    /**
     * schedule.
     * @param instant instant
     * @param iocJob iocJob
     * @param id id
     * @param  S
     * @return JobId
     */
    default  JobId schedule(UUID id, Instant instant, IocJobLambda iocJob) {
        return BackgroundJob.schedule(id, instant, iocJob);
    }

    /**
     * scheduleRecurrently.
     * @param cron cron
     * @param job job
     * @param id id
     * @return String
     */
    default String scheduleRecurrently(String id, String cron, JobLambda job) {
        return BackgroundJob.scheduleRecurrently(id, cron, job);
    }

    /**
     * scheduleRecurrently.
     * @param cron cron
     * @param iocJob iocJob
     * @param id id
     * @param  S
     * @return String
     */
    default  String scheduleRecurrently(String id, String cron, IocJobLambda iocJob) {
        return BackgroundJob.scheduleRecurrently(id, cron, iocJob);
    }

    /**
     * scheduleRecurrently.
     * @param cron cron
     * @param job job
     * @param zoneId zoneId
     * @param id id
     * @return String
     */
    default String scheduleRecurrently(String id, String cron, ZoneId zoneId, JobLambda job) {
        return BackgroundJob.scheduleRecurrently(id, cron, zoneId, job);
    }

    /**
     * scheduleRecurrently.
     * @param cron cron
     * @param zoneId zoneId
     * @param zoneId zoneId
     * @param iocJob iocJob
     * @param id id id
     * @return String
     * @param  S
     */
    default  String scheduleRecurrently(String id, String cron, ZoneId zoneId, IocJobLambda iocJob) {
        return BackgroundJob.scheduleRecurrently(id, cron, zoneId, iocJob);
    }

    /**
     * scheduleRecurrently.
     * @param id id
     */
    default void delete(String id) {
        BackgroundJob.delete(id);
    }

    /**
     * close.
     */
    @Override
    void close();
}