本文整理了Java中io.github.resilience4j.bulkhead.Bulkhead.onComplete()
方法的一些代码示例,展示了Bulkhead.onComplete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bulkhead.onComplete()
方法的具体详情如下:
包路径:io.github.resilience4j.bulkhead.Bulkhead
类名称:Bulkhead
方法名:onComplete
[英]Records a completed call.
[中]记录已完成的呼叫。
代码示例来源:origin: resilience4j/resilience4j
private void releaseBulkhead() {
if (permitted.compareAndSet(Permit.ACQUIRED, Permit.RELEASED)) {
bulkhead.onComplete();
}
}
}
代码示例来源:origin: resilience4j/resilience4j
private void releaseBulkhead() {
if (wasCallPermitted()) {
bulkhead.onComplete();
}
}
}
代码示例来源:origin: resilience4j/resilience4j
private void releaseBulkhead() {
if (wasCallPermitted()) {
bulkhead.onComplete();
}
}
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a callable which is decorated by a bulkhead.
*
* @param bulkhead the bulkhead
* @param callable the original Callable
* @param <T> the result type of callable
*
* @return a supplier which is decorated by a Bulkhead.
*/
static <T> Callable<T> decorateCallable(Bulkhead bulkhead, Callable<T> callable){
return () -> {
BulkheadUtils.isCallPermitted(bulkhead);
try {
return callable.call();
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a consumer which is decorated by a bulkhead.
* @param bulkhead the bulkhead
* @param consumer the original consumer
* @param <T> the type of the input to the consumer
*
* @return a consumer which is decorated by a Bulkhead.
*/
static <T> Consumer<T> decorateConsumer(Bulkhead bulkhead, Consumer<T> consumer){
return (t) -> {
BulkheadUtils.isCallPermitted(bulkhead);
try {
consumer.accept(t);
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a runnable which is decorated by a bulkhead.
*
* @param bulkhead the bulkhead
* @param runnable the original runnable
*
* @return a runnable which is decorated by a bulkhead.
*/
static Runnable decorateRunnable(Bulkhead bulkhead, Runnable runnable){
return () -> {
BulkheadUtils.isCallPermitted(bulkhead);
try{
runnable.run();
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a function which is decorated by a bulkhead.
* @param bulkhead the bulkhead
* @param function the original function
* @param <T> the type of the input to the function
* @param <R> the type of the result of the function
* @return a function which is decorated by a bulkhead.
*/
static <T, R> Function<T, R> decorateFunction(Bulkhead bulkhead, Function<T, R> function){
return (T t) -> {
BulkheadUtils.isCallPermitted(bulkhead);
try{
return function.apply(t);
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a supplier which is decorated by a bulkhead.
*
* @param bulkhead the bulkhead
* @param supplier the original supplier
* @param <T> the type of results supplied by this supplier
*
* @return a supplier which is decorated by a Bulkhead.
*/
static <T> Supplier<T> decorateSupplier(Bulkhead bulkhead, Supplier<T> supplier){
return () -> {
BulkheadUtils.isCallPermitted(bulkhead);
try {
return supplier.get();
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public void onError(Throwable e) {
if (isInvocationPermitted()) {
bulkhead.onComplete();
childSubscriber.onError(e);
}
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public void hookOnError(Throwable t) {
if (wasCallPermitted()) {
bulkhead.onComplete();
actual.onError(t);
}
}
代码示例来源:origin: resilience4j/resilience4j
.whenComplete(
(result, throwable) -> {
bulkhead.onComplete();
if (throwable != null) {
promise.completeExceptionally(throwable);
bulkhead.onComplete();
promise.completeExceptionally(throwable);
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a consumer which is decorated by a bulkhead.
* @param bulkhead the bulkhead
* @param consumer the original consumer
* @param <T> the type of the input to the consumer
*
* @return a consumer which is decorated by a Bulkhead.
*/
static <T> CheckedConsumer<T> decorateCheckedConsumer(Bulkhead bulkhead, CheckedConsumer<T> consumer){
return (t) -> {
BulkheadUtils.isCallPermitted(bulkhead);
try {
consumer.accept(t);
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a function which is decorated by a bulkhead.
*
* @param bulkhead the bulkhead
* @param function the original function
* @param <T> the type of the input to the function
* @param <R> the type of the result of the function
* @return a function which is decorated by a bulkhead.
*/
static <T, R> CheckedFunction1<T, R> decorateCheckedFunction(Bulkhead bulkhead, CheckedFunction1<T, R> function){
return (T t) -> {
BulkheadUtils.isCallPermitted(bulkhead);
try{
return function.apply(t);
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a supplier which is decorated by a bulkhead.
*
* @param bulkhead the Bulkhead
* @param supplier the original supplier
* @param <T> the type of results supplied by this supplier
* @return a supplier which is decorated by a Bulkhead.
*/
static <T> CheckedFunction0<T> decorateCheckedSupplier(Bulkhead bulkhead, CheckedFunction0<T> supplier){
return () -> {
BulkheadUtils.isCallPermitted(bulkhead);
try {
return supplier.apply();
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
/**
* Returns a runnable which is decorated by a bulkhead.
*
* @param bulkhead the bulkhead
* @param runnable the original runnable
*
* @return a runnable which is decorated by a Bulkhead.
*/
static CheckedRunnable decorateCheckedRunnable(Bulkhead bulkhead, CheckedRunnable runnable){
return () -> {
BulkheadUtils.isCallPermitted(bulkhead);
try{
runnable.run();
}
finally {
bulkhead.onComplete();
}
};
}
代码示例来源:origin: resilience4j/resilience4j
private Object handleOther(MethodInvocation invocation, io.github.resilience4j.bulkhead.Bulkhead bulkhead, RecoveryFunction<?> recoveryFunction) throws Throwable {
boolean permission = bulkhead.isCallPermitted();
if (!permission) {
Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
return recoveryFunction.apply(t);
}
try {
if (Thread.interrupted()) {
throw new IllegalStateException("Thread was interrupted during permission wait");
}
return invocation.proceed();
} catch (Exception e) {
return recoveryFunction.apply(e);
} finally {
bulkhead.onComplete();
}
}
}
代码示例来源:origin: resilience4j/resilience4j
if (bulkhead.isCallPermitted()) {
return ((CompletionStage<?>) invocation.proceed()).handle((o, throwable) -> {
bulkhead.onComplete();
if (throwable != null) {
try {
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testBulkhead() throws InterruptedException {
bulkhead.isCallPermitted();
bulkhead.isCallPermitted();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(0);
bulkhead.isCallPermitted();
bulkhead.onComplete();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
bulkhead.onComplete();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(2);
bulkhead.isCallPermitted();
testSubscriber.assertValueCount(6)
.assertValues(CALL_PERMITTED, CALL_PERMITTED, CALL_REJECTED, CALL_FINISHED, CALL_FINISHED, CALL_PERMITTED);
}
代码示例来源: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: io.github.resilience4j/resilience4j-rxjava2
private void releaseBulkhead() {
if (permitted.compareAndSet(Permit.ACQUIRED, Permit.RELEASED)) {
bulkhead.onComplete();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!