本文整理了Java中io.github.resilience4j.bulkhead.Bulkhead.decorateRunnable()
方法的一些代码示例,展示了Bulkhead.decorateRunnable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bulkhead.decorateRunnable()
方法的具体详情如下:
包路径:io.github.resilience4j.bulkhead.Bulkhead
类名称:Bulkhead
方法名:decorateRunnable
[英]Returns a runnable which is decorated by a bulkhead.
[中]返回由隔板装饰的可运行文件。
代码示例来源:origin: resilience4j/resilience4j
public DecorateRunnable withBulkhead(Bulkhead bulkhead) {
runnable = Bulkhead.decorateRunnable(bulkhead, runnable);
return this;
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Decorates and executes the decorated Runnable.
*
* @param runnable the original Runnable
*/
default void executeRunnable(Runnable runnable){
decorateRunnable(this, runnable).run();
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldDecorateRunnableAndReturnWithException() throws Throwable {
// Given
Bulkhead bulkhead = Bulkhead.of("test", config);
// When
Runnable runnable = Bulkhead.decorateRunnable(bulkhead, () -> {throw new RuntimeException("BAM!");});
Try<Void> result = Try.run(runnable::run);
//Then
assertThat(result.isFailure()).isTrue();
assertThat(result.failed().get()).isInstanceOf(RuntimeException.class);
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldDecorateRunnableAndReturnWithSuccess() throws Throwable {
// Given
Bulkhead bulkhead = Bulkhead.of("test", config);
//When
Bulkhead.decorateRunnable(bulkhead, helloWorldService::sayHelloWorld)
.run();
//Then
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
BDDMockito.then(helloWorldService).should(times(1)).sayHelloWorld();
}
内容来源于网络,如有侵权,请联系作者删除!