本文整理了Java中io.github.resilience4j.bulkhead.Bulkhead.getEventPublisher()
方法的一些代码示例,展示了Bulkhead.getEventPublisher()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bulkhead.getEventPublisher()
方法的具体详情如下:
包路径:io.github.resilience4j.bulkhead.Bulkhead
类名称:Bulkhead
方法名:getEventPublisher
[英]Returns an EventPublisher which subscribes to the reactive stream of BulkheadEvent and can be used to register event consumers.
[中]返回订阅BulkheadEvent的反应流并可用于注册事件使用者的EventPublisher。
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldReturnTheSameConsumer() {
Bulkhead.EventPublisher eventPublisher = bulkhead.getEventPublisher();
Bulkhead.EventPublisher eventPublisher2 = bulkhead.getEventPublisher();
assertThat(eventPublisher).isEqualTo(eventPublisher2);
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldConsumeOnCallFinishedEventOnComplete() throws Exception {
// Given
Bulkhead bulkhead = Bulkhead.of("test", config);
// When
bulkhead.getEventPublisher()
.onCallFinished(event ->
logger.info(event.getEventType().toString()));
bulkhead.onComplete();
// Then
then(logger).should(times(1)).info("CALL_FINISHED");
}
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldConsumeOnCallFinishedEventWhenExecutionIsFinished() throws Exception {
// Given
Bulkhead bulkhead = Bulkhead.of("test", config);
// When
bulkhead.getEventPublisher()
.onCallFinished(event ->
logger.info(event.getEventType().toString()));
Try.ofSupplier(Bulkhead.decorateSupplier(bulkhead,helloWorldService::returnHelloWorld));
// Then
then(logger).should(times(1)).info("CALL_FINISHED");
}
代码示例来源: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
@Test
public void shouldConsumeOnCallRejectedEvent() {
// Given
Bulkhead bulkhead = Bulkhead.of("test", config);
// When
bulkhead.getEventPublisher()
.onCallRejected(event ->
logger.info(event.getEventType().toString()));
bulkhead.isCallPermitted();
Try.ofSupplier(Bulkhead.decorateSupplier(bulkhead,helloWorldService::returnHelloWorld));
// Then
then(logger).should(times(1)).info("CALL_REJECTED");
}
代码示例来源:origin: resilience4j/resilience4j
bulkhead.getEventPublisher().onEvent(bConsumerRegistry.createEventConsumer(name, endpointsConfig.getBulkheads().getEventConsumerBufferSize()));
代码示例来源:origin: resilience4j/resilience4j
@Before
public void setUp() {
BulkheadConfig config = BulkheadConfig.custom()
.maxConcurrentCalls(2)
.maxWaitTime(0)
.build();
bulkhead = Bulkhead.of("test", config);
testSubscriber = RxJava2Adapter.toFlowable(bulkhead.getEventPublisher())
.map(BulkheadEvent::getEventType)
.test();
}
代码示例来源:origin: resilience4j/resilience4j
);
chain1.get("stream/events", ctx -> {
Seq<Flux<BulkheadEvent>> eventStreams = bulkheadRegistry.getAllBulkheads().map(bulkhead -> ReactorAdapter.toFlux(bulkhead.getEventPublisher()));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data));
.getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
ServerSentEvents events = ServerSentEvents.serverSentEvents(ReactorAdapter.toFlux(bulkhead.getEventPublisher()), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data));
ctx.render(events);
});
Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
.getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())
.filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase()));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
代码示例来源:origin: io.github.resilience4j/resilience4j-ratpack
bulkhead.getEventPublisher().onEvent(bConsumerRegistry.createEventConsumer(name, endpointsConfig.getBulkheads().getEventConsumerBufferSize()));
代码示例来源:origin: io.github.resilience4j/resilience4j-ratpack
);
chain1.get("stream/events", ctx -> {
Seq<Flux<BulkheadEvent>> eventStreams = bulkheadRegistry.getAllBulkheads().map(bulkhead -> ReactorAdapter.toFlux(bulkhead.getEventPublisher()));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data));
.getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
ServerSentEvents events = ServerSentEvents.serverSentEvents(ReactorAdapter.toFlux(bulkhead.getEventPublisher()), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data));
ctx.render(events);
});
Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
.getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())
.filter(event -> event.getEventType() == BulkheadEvent.Type.valueOf(eventType.toUpperCase()));
Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
内容来源于网络,如有侵权,请联系作者删除!