diff --git a/extensions/smallrye-fault-tolerance/deployment/pom.xml b/extensions/smallrye-fault-tolerance/deployment/pom.xml index fd9e77ed49a3a..61a82927cc3f2 100644 --- a/extensions/smallrye-fault-tolerance/deployment/pom.xml +++ b/extensions/smallrye-fault-tolerance/deployment/pom.xml @@ -10,7 +10,7 @@ 4.0.0 quarkus-smallrye-fault-tolerance-deployment - Quarkus - SmallRye Fault tolerance - Deployment + Quarkus - SmallRye Fault Tolerance - Deployment diff --git a/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/devconsole/FaultToleranceDevConsoleProcessor.java b/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/devconsole/FaultToleranceDevConsoleProcessor.java new file mode 100644 index 0000000000000..e7dd5e100d5b4 --- /dev/null +++ b/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/devconsole/FaultToleranceDevConsoleProcessor.java @@ -0,0 +1,15 @@ +package io.quarkus.smallrye.faulttolerance.deployment.devconsole; + +import io.quarkus.deployment.IsDevelopment; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; +import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem; +import io.quarkus.smallrye.faulttolerance.runtime.FaultToleranceOperationsDevConsoleSupplier; + +public class FaultToleranceDevConsoleProcessor { + @BuildStep(onlyIf = IsDevelopment.class) + DevConsoleRuntimeTemplateInfoBuildItem collectInfo(CurateOutcomeBuildItem curateOutcome) { + return new DevConsoleRuntimeTemplateInfoBuildItem("ftOperations", new FaultToleranceOperationsDevConsoleSupplier(), + this.getClass(), curateOutcome); + } +} diff --git a/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/embedded.html b/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/embedded.html new file mode 100644 index 0000000000000..40e9ef05001ba --- /dev/null +++ b/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/embedded.html @@ -0,0 +1,3 @@ + + + Guarded Methods {info:ftOperations.size} diff --git a/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/ft-operations.html b/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/ft-operations.html new file mode 100644 index 0000000000000..e9cf6b7635774 --- /dev/null +++ b/extensions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/ft-operations.html @@ -0,0 +1,144 @@ +{#include main fluid=true} + {#style} + .annotation { + color: gray; + font-style: italic; + } + span.larger-badge { + font-size: 0.9em; + } + span.app-class { + cursor:pointer; + color:blue; + text-decoration:underline; + } + {/style} + + {#script} + $(document).ready(function(){ + if (!ideKnown()) { + return; + } + $(".class-candidate").each(function() { + var className = $(this).text(); + if (appClassLocation(className)) { + $(this).addClass("app-class"); + } + }); + + $(".app-class").on("click", function() { + openInIDE($(this).text()); + }); + }); + {/script} + + {#title}Guarded Methods{/title} + + {#body} + + + + + + + + + + + {#for ftOperation in info:ftOperations} + + + + + + + {/for} + +
#Bean ClassMethodFault Tolerance Strategies
{ftOperation_count} + {#if ftOperation.beanClass.name.length > 70}{ftOperation.beanClass.name.substring(0,70)}...{#else}{ftOperation.beanClass.name}{/if} + + {ftOperation.methodDescriptor.name}() + +
    + {#if ftOperation.applyFaultTolerance} +
  • + @ApplyFaultTolerance("{ftOperation.applyFaultTolerance.value}") +
  • + {/if} + + {#if ftOperation.asynchronous} +
  • @Asynchronous
  • + {/if} + + {#if ftOperation.blocking} +
  • @Blocking
  • + {/if} + + {#if ftOperation.nonBlocking} +
  • @NonBlocking
  • + {/if} + + {#if ftOperation.bulkhead} +
  • @Bulkhead(value = {ftOperation.bulkhead.value}, + waitingTaskQueue = {ftOperation.bulkhead.waitingTaskQueue})
  • + {/if} + + {#if ftOperation.circuitBreaker} +
  • + @CircuitBreaker(delay = {ftOperation.circuitBreaker.delay} {ftOperation.circuitBreaker.delayUnit.name}, + requestVolumeThreshold = {ftOperation.circuitBreaker.requestVolumeThreshold}, + failureRatio = {ftOperation.circuitBreaker.failureRatio}, + successThreshold = {ftOperation.circuitBreaker.successThreshold}, + failOn = [{#each ftOperation.circuitBreaker.failOn}{it.name}{#if it_hasNext}, {/if}{/each}], + skipOn = [{#each ftOperation.circuitBreaker.skipOn}{it.name}{#if it_hasNext}, {/if}{/each}]) + {#if ftOperation.circuitBreakerName} +
      +
    • @CircuitBreakerName("{ftOperation.circuitBreakerName.value}")
    • +
    + {/if} +
  • + {/if} + + {#if ftOperation.fallback} +
  • + @Fallback(value = {ftOperation.fallback.value.name}, + fallbackMethod = "{ftOperation.fallback.fallbackMethod}", + applyOn = [{#each ftOperation.fallback.applyOn}{it.name}{#if it_hasNext}, {/if}{/each}], + skipOn = [{#each ftOperation.fallback.skipOn}{it.name}{#if it_hasNext}, {/if}{/each}]) +
  • + {/if} + + {#if ftOperation.retry} +
  • + @Retry(maxRetries = {ftOperation.retry.maxRetries}, + delay = {ftOperation.retry.delay} {ftOperation.retry.delayUnit.name}, + maxDuration = {ftOperation.retry.maxDuration} {ftOperation.retry.durationUnit.name}, + jitter = {ftOperation.retry.jitter} {ftOperation.retry.jitterDelayUnit.name}, + retryOn = [{#each ftOperation.retry.retryOn}{it.name}{#if it_hasNext}, {/if}{/each}], + abortOn = [{#each ftOperation.retry.abortOn}{it.name}{#if it_hasNext}, {/if}{/each}]) + {#if ftOperation.exponentialBackoff || ftOperation.fibonacciBackoff || ftOperation.customBackoff} +
      + {#if ftOperation.exponentialBackoff} +
    • @ExponentialBackoff(factor = {ftOperation.exponentialBackoff.factor}, + maxDelay = {ftOperation.exponentialBackoff.maxDelay} {ftOperation.exponentialBackoff.maxDelayUnit.name})
    • + {/if} + {#if ftOperation.fibonacciBackoff} +
    • @FibonacciBackoff(maxDelay = {ftOperation.fibonacciBackoff.maxDelay} {ftOperation.fibonacciBackoff.maxDelayUnit.name})
    • + {/if} + {#if ftOperation.customBackoff} +
    • @CustomBackoff({ftOperation.customBackoff.value.name})
    • + {/if} +
    + {/if} +
  • + {/if} + + {#if ftOperation.timeout} +
  • + @Timeout({ftOperation.timeout.value} {ftOperation.timeout.unit.name}) +
  • + {/if} +
+
+ {/body} +{/include} diff --git a/extensions/smallrye-fault-tolerance/pom.xml b/extensions/smallrye-fault-tolerance/pom.xml index b297446b0d4d3..eb9091a4f1c98 100644 --- a/extensions/smallrye-fault-tolerance/pom.xml +++ b/extensions/smallrye-fault-tolerance/pom.xml @@ -11,7 +11,7 @@ 4.0.0 quarkus-smallrye-fault-tolerance-parent - Quarkus - SmallRye Fault tolerance + Quarkus - SmallRye Fault Tolerance pom diff --git a/extensions/smallrye-fault-tolerance/runtime/pom.xml b/extensions/smallrye-fault-tolerance/runtime/pom.xml index ab3470d180e1d..43c7e01478e65 100644 --- a/extensions/smallrye-fault-tolerance/runtime/pom.xml +++ b/extensions/smallrye-fault-tolerance/runtime/pom.xml @@ -10,8 +10,8 @@ 4.0.0 quarkus-smallrye-fault-tolerance - Quarkus - SmallRye Fault tolerance - Runtime - Define fault-tolerant services + Quarkus - SmallRye Fault Tolerance - Runtime + Build fault-tolerant network services io.quarkus diff --git a/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/FaultToleranceOperationsDevConsoleSupplier.java b/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/FaultToleranceOperationsDevConsoleSupplier.java new file mode 100644 index 0000000000000..71d4898fd8e46 --- /dev/null +++ b/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/FaultToleranceOperationsDevConsoleSupplier.java @@ -0,0 +1,23 @@ +package io.quarkus.smallrye.faulttolerance.runtime; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.function.Supplier; + +import io.quarkus.arc.Arc; +import io.smallrye.faulttolerance.config.FaultToleranceOperation; + +public class FaultToleranceOperationsDevConsoleSupplier implements Supplier> { + @Override + public List get() { + QuarkusFaultToleranceOperationProvider provider = Arc.container() + .select(QuarkusFaultToleranceOperationProvider.class).get(); + List operations = new ArrayList<>(provider.getOperationCache().values()); + operations.sort(Comparator.comparing(FaultToleranceOperation::getName)); + for (FaultToleranceOperation operation : operations) { + operation.materialize(); + } + return operations; + } +} diff --git a/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/QuarkusFaultToleranceOperationProvider.java b/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/QuarkusFaultToleranceOperationProvider.java index 85b41aa7b784c..53614d3f24126 100644 --- a/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/QuarkusFaultToleranceOperationProvider.java +++ b/extensions/smallrye-fault-tolerance/runtime/src/main/java/io/quarkus/smallrye/faulttolerance/runtime/QuarkusFaultToleranceOperationProvider.java @@ -49,6 +49,10 @@ private FaultToleranceOperation createAtRuntime(CacheKey key) { return FaultToleranceOperation.create(FaultToleranceMethods.create(key.beanClass, key.method)); } + Map getOperationCache() { + return operationCache; + } + static class CacheKey { private Class beanClass; private Method method;