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

dev.sixpack.generator.GenerationWi Maven / Gradle / Ivy

The newest version!
package dev.sixpack.generator;

import dev.sixpack.api.data.Request;
import dev.sixpack.api.data.Result;
import dev.sixpack.api.rpc.AbstractWorkflow;
import dev.sixpack.api.rpc.GenerationW;
import dev.sixpack.api.rpc.GeneratorA;
import io.temporal.workflow.Workflow;
import org.slf4j.Logger;

import static io.temporal.workflow.Workflow.newActivityStub;

public class GenerationWi extends AbstractWorkflow implements GenerationW {
    protected final Logger LOGGER;

    private final FactoryRecord factoryRecord;

    public GenerationWi(FactoryRecord factoryRecord) {
        this.factoryRecord = factoryRecord;
        LOGGER = Workflow.getLogger(factoryRecord.getItem());
    }

    @Override
    public Result generate(Request request) {
        Result result;
        if (factoryRecord.getOrchestrator() != null) {
            result = FactoryController.generateWithRetries(request, LOGGER, factoryRecord);
        } else {
            GeneratorA generator = newActivityStub(
                GeneratorA.class,
                GeneratorA.options(
                    factoryRecord.getEnvironment(),
                    factoryRecord.getSupplier(),
                    factoryRecord.getItem()));
            result = generator.generate(request);
        }
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy