io.github.resilience4j.bulkhead.Bulkhead.executeSupplier()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中io.github.resilience4j.bulkhead.Bulkhead.executeSupplier()方法的一些代码示例,展示了Bulkhead.executeSupplier()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bulkhead.executeSupplier()方法的具体详情如下:
包路径:io.github.resilience4j.bulkhead.Bulkhead
类名称:Bulkhead
方法名:executeSupplier

Bulkhead.executeSupplier介绍

[英]Decorates and executes the decorated Supplier.
[中]装饰并执行装饰供应商。

代码示例

代码示例来源:origin: resilience4j/resilience4j

@Test
public void shouldExecuteSupplierAndReturnWithSuccess() {
  // Given
  Bulkhead bulkhead = Bulkhead.of("test", config);
  BDDMockito.given(helloWorldService.returnHelloWorld()).willReturn("Hello world");
  // When
  String result = bulkhead.executeSupplier(helloWorldService::returnHelloWorld);
  // Then
  assertThat(result).isEqualTo("Hello world");
  assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
  BDDMockito.then(helloWorldService).should(times(1)).returnHelloWorld();
}

代码示例来源:origin: resilience4j/resilience4j

@Test
public void shouldConsumeOnCallPermittedEvent() {
  // Given
  Bulkhead bulkhead = Bulkhead.of("test", config);
  BDDMockito.given(helloWorldService.returnHelloWorld()).willReturn("Hello world");
  // When
  bulkhead.getEventPublisher()
    .onCallPermitted(event ->
        logger.info(event.getEventType().toString()));
  String result = bulkhead.executeSupplier(helloWorldService::returnHelloWorld);
  // Then
  assertThat(result).isEqualTo("Hello world");
  then(logger).should(times(1)).info("CALL_PERMITTED");
}

代码示例来源:origin: resilience4j/resilience4j

Future<String> future = executorService.submit(() -> bulkhead.executeSupplier(helloWorldService::returnHelloWorld));

代码示例来源:origin: resilience4j/resilience4j

Future<String> future = executorService.submit(() -> bulkhead.executeSupplier(helloWorldService::returnHelloWorld));

相关文章