io.github.anicolaspp.Hx.commands.CommandWithFallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HxFactory Show documentation
Show all versions of HxFactory Show documentation
Factory library to create and run Hystrix commands with simplicity
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();
}
}