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

io.github.anicolaspp.Hx.commands.CommandWithFallback Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package io.github.anicolaspp.Hx.commands;

import io.github.anicolaspp.Hx.BreakerSupplier;
import com.netflix.hystrix.HystrixCommand;

import java.util.function.Supplier;

class CommandWithFallback extends HystrixCommand {
    
    private final BreakerSupplier supplier;
    private final Supplier fallback;
    
    CommandWithFallback(BreakerSupplier supplier,
                        Supplier fallback,
                        Setter setter) {
        super(setter);
        
        this.supplier = supplier;
        this.fallback = fallback;
    }
    
    @Override
    protected Result run() throws Exception {
        return supplier.get();
    }
    
    @Override
    public Result getFallback() {
        return fallback.get();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy