-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26403 from Ladicek/fault-tolerance-dev-ui
Add dev UI for SmallRye Fault Tolerance
- Loading branch information
Showing
8 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...rkus/smallrye/faulttolerance/deployment/devconsole/FaultToleranceDevConsoleProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...nsions/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/embedded.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<a href="{urlbase}/ft-operations" class="badge badge-light"> | ||
<i class="fa fa-life-ring fa-fw"></i> | ||
Guarded Methods <span class="badge badge-light">{info:ftOperations.size}</span></a> |
144 changes: 144 additions & 0 deletions
144
...s/smallrye-fault-tolerance/deployment/src/main/resources/dev-templates/ft-operations.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
<table class="table table-striped"> | ||
<thead class="thead-dark"> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Bean Class</th> | ||
<th scope="col">Method</th> | ||
<th scope="col">Fault Tolerance Strategies</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{#for ftOperation in info:ftOperations} | ||
<tr> | ||
<td>{ftOperation_count}</td> | ||
<td> | ||
<span class="class-candidate" title="{ftOperation.beanClass.name}">{#if ftOperation.beanClass.name.length > 70}{ftOperation.beanClass.name.substring(0,70)}...{#else}{ftOperation.beanClass.name}{/if}</span> | ||
</td> | ||
<td> | ||
<code><span title="{ftOperation.methodDescriptor.declaringClass.name}#{ftOperation.methodDescriptor.name}()">{ftOperation.methodDescriptor.name}()</span></code> | ||
</td> | ||
<td> | ||
<ul> | ||
{#if ftOperation.applyFaultTolerance} | ||
<li> | ||
@ApplyFaultTolerance<span class="annotation">("{ftOperation.applyFaultTolerance.value}")</span> | ||
</li> | ||
{/if} | ||
|
||
{#if ftOperation.asynchronous} | ||
<li>@Asynchronous</li> | ||
{/if} | ||
|
||
{#if ftOperation.blocking} | ||
<li>@Blocking</li> | ||
{/if} | ||
|
||
{#if ftOperation.nonBlocking} | ||
<li>@NonBlocking</li> | ||
{/if} | ||
|
||
{#if ftOperation.bulkhead} | ||
<li>@Bulkhead<span class="annotation">(value = {ftOperation.bulkhead.value}, | ||
waitingTaskQueue = {ftOperation.bulkhead.waitingTaskQueue})</span></li> | ||
{/if} | ||
|
||
{#if ftOperation.circuitBreaker} | ||
<li> | ||
@CircuitBreaker<span class="annotation">(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}])</span> | ||
{#if ftOperation.circuitBreakerName} | ||
<ul> | ||
<li>@CircuitBreakerName<span class="annotation">("{ftOperation.circuitBreakerName.value}")</span></li> | ||
</ul> | ||
{/if} | ||
</li> | ||
{/if} | ||
|
||
{#if ftOperation.fallback} | ||
<li> | ||
@Fallback<span class="annotation">(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}])</span> | ||
</li> | ||
{/if} | ||
|
||
{#if ftOperation.retry} | ||
<li> | ||
@Retry<span class="annotation">(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}])</span> | ||
{#if ftOperation.exponentialBackoff || ftOperation.fibonacciBackoff || ftOperation.customBackoff} | ||
<ul> | ||
{#if ftOperation.exponentialBackoff} | ||
<li>@ExponentialBackoff<span class="annotation">(factor = {ftOperation.exponentialBackoff.factor}, | ||
maxDelay = {ftOperation.exponentialBackoff.maxDelay} {ftOperation.exponentialBackoff.maxDelayUnit.name})</span></li> | ||
{/if} | ||
{#if ftOperation.fibonacciBackoff} | ||
<li>@FibonacciBackoff<span class="annotation">(maxDelay = {ftOperation.fibonacciBackoff.maxDelay} {ftOperation.fibonacciBackoff.maxDelayUnit.name})</span></li> | ||
{/if} | ||
{#if ftOperation.customBackoff} | ||
<li>@CustomBackoff<span class="annotation">({ftOperation.customBackoff.value.name})</span></li> | ||
{/if} | ||
</ul> | ||
{/if} | ||
</li> | ||
{/if} | ||
|
||
{#if ftOperation.timeout} | ||
<li> | ||
@Timeout<span class="annotation">({ftOperation.timeout.value} {ftOperation.timeout.unit.name})</span> | ||
</li> | ||
{/if} | ||
</ul> | ||
</td> | ||
</tr> | ||
{/for} | ||
</tbody> | ||
</table> | ||
{/body} | ||
{/include} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...o/quarkus/smallrye/faulttolerance/runtime/FaultToleranceOperationsDevConsoleSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<List<FaultToleranceOperation>> { | ||
@Override | ||
public List<FaultToleranceOperation> get() { | ||
QuarkusFaultToleranceOperationProvider provider = Arc.container() | ||
.select(QuarkusFaultToleranceOperationProvider.class).get(); | ||
List<FaultToleranceOperation> operations = new ArrayList<>(provider.getOperationCache().values()); | ||
operations.sort(Comparator.comparing(FaultToleranceOperation::getName)); | ||
for (FaultToleranceOperation operation : operations) { | ||
operation.materialize(); | ||
} | ||
return operations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters