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

org.jetlinks.rule.engine.defaults.LambdaTaskExecutorProvider Maven / Gradle / Ivy

The newest version!
package org.jetlinks.rule.engine.defaults;

import org.jetlinks.rule.engine.api.RuleData;
import org.jetlinks.rule.engine.api.task.ExecutionContext;
import org.jetlinks.rule.engine.api.task.TaskExecutor;
import org.jetlinks.rule.engine.api.task.TaskExecutorProvider;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;

import java.util.function.Function;

public class LambdaTaskExecutorProvider implements TaskExecutorProvider {
    private final Function> function;

    private final String executor;

    private final String name;

    public LambdaTaskExecutorProvider(String executor, Function> function) {
        this(executor, executor, function);
    }

    public LambdaTaskExecutorProvider(String executor, String name, Function> function) {
        this.function = function;
        this.executor = executor;
        this.name = name;
    }

    @Override
    public String getExecutor() {
        return executor;
    }

    @Override
    public Mono createTask(ExecutionContext context) {
        return Mono.just(new LambdaTaskExecutor(name, context,function));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy