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

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

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

import com.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