-
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 #31902 from Ladicek/fault-tolerance-devui
Dev UI: SmallRye Fault Tolerance
- Loading branch information
Showing
9 changed files
with
419 additions
and
11 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
30 changes: 30 additions & 0 deletions
30
...ava/io/quarkus/smallrye/faulttolerance/deployment/devui/FaultToleranceDevUIProcessor.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,30 @@ | ||
package io.quarkus.smallrye.faulttolerance.deployment.devui; | ||
|
||
import io.quarkus.deployment.IsDevelopment; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; | ||
import io.quarkus.devui.spi.page.CardPageBuildItem; | ||
import io.quarkus.devui.spi.page.Page; | ||
import io.quarkus.smallrye.faulttolerance.runtime.devui.FaultToleranceJsonRpcService; | ||
|
||
public class FaultToleranceDevUIProcessor { | ||
private static final String NAME = "SmallRye Fault Tolerance"; | ||
|
||
@BuildStep(onlyIf = IsDevelopment.class) | ||
CardPageBuildItem cardPage(FaultToleranceInfoBuildItem faultToleranceInfo) { | ||
CardPageBuildItem pageBuildItem = new CardPageBuildItem(NAME); | ||
|
||
pageBuildItem.addPage(Page.webComponentPageBuilder() | ||
.title("Guarded Methods") | ||
.icon("font-awesome-solid:life-ring") | ||
.componentLink("qwc-fault-tolerance-methods.js") | ||
.staticLabel("" + faultToleranceInfo.getGuardedMethods())); | ||
|
||
return pageBuildItem; | ||
} | ||
|
||
@BuildStep(onlyIf = IsDevelopment.class) | ||
JsonRPCProvidersBuildItem jsonRPCService() { | ||
return new JsonRPCProvidersBuildItem(NAME, FaultToleranceJsonRpcService.class); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...java/io/quarkus/smallrye/faulttolerance/deployment/devui/FaultToleranceInfoBuildItem.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.devui; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
public final class FaultToleranceInfoBuildItem extends SimpleBuildItem { | ||
private final int guardedMethods; | ||
|
||
public FaultToleranceInfoBuildItem(int guardedMethods) { | ||
this.guardedMethods = guardedMethods; | ||
} | ||
|
||
public int getGuardedMethods() { | ||
return guardedMethods; | ||
} | ||
} |
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
198 changes: 198 additions & 0 deletions
198
...loyment/src/main/resources/dev-ui/smallrye-fault-tolerance/qwc-fault-tolerance-methods.js
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,198 @@ | ||
import {css, html, LitElement} from 'lit'; | ||
import {until} from 'lit/directives/until.js'; | ||
import {JsonRpc} from 'jsonrpc'; | ||
import '@vaadin/grid'; | ||
import {columnBodyRenderer} from '@vaadin/grid/lit.js'; | ||
import '@vaadin/vertical-layout'; | ||
|
||
export class QwcFaultToleranceMethods extends LitElement { | ||
jsonRpc = new JsonRpc('SmallRye Fault Tolerance'); | ||
|
||
static styles = css` | ||
vaadin-grid { | ||
height: 100%; | ||
padding-bottom: 10px; | ||
} | ||
.method { | ||
color: var(--lumo-primary-text-color); | ||
} | ||
`; | ||
|
||
static properties = { | ||
_guardedMethods: {state: true}, | ||
}; | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
this._refresh(); | ||
} | ||
|
||
render() { | ||
return html`${until(this._renderGuardedMethods(), html`<span>Loading guarded methods...</span>`)}`; | ||
} | ||
|
||
_renderGuardedMethods() { | ||
if (this._guardedMethods) { | ||
return html` | ||
<vaadin-grid .items="${this._guardedMethods}" theme="no-border"> | ||
<vaadin-grid-column header="Bean Class" auto-width flex-grow="0" | ||
${columnBodyRenderer(this._renderBeanClass, [])} | ||
resizable> | ||
</vaadin-grid-column> | ||
<vaadin-grid-column header="Method" auto-width flex-grow="0" | ||
${columnBodyRenderer(this._renderMethodName, [])} | ||
resizable> | ||
</vaadin-grid-column> | ||
<vaadin-grid-column header="Fault Tolerance Strategies" auto-width flex-grow="0" | ||
${columnBodyRenderer(this._renderStrategies, [])} | ||
resizable> | ||
</vaadin-grid-column> | ||
</vaadin-grid> | ||
`; | ||
} | ||
} | ||
|
||
_renderBeanClass(guardedMethod) { | ||
return html` | ||
<code>${guardedMethod.beanClass}</code> | ||
`; | ||
} | ||
|
||
_renderMethodName(guardedMethod) { | ||
return html` | ||
<code class="method">${guardedMethod.method}()</code> | ||
`; | ||
} | ||
|
||
_renderStrategies(guardedMethod) { | ||
return html` | ||
<vaadin-vertical-layout> | ||
${guardedMethod.ApplyFaultTolerance ? this._renderApplyFaultTolerance(guardedMethod.ApplyFaultTolerance) : html``} | ||
${guardedMethod.Asynchronous ? html`<span>@Asynchronous</span>` : html``} | ||
${guardedMethod.AsynchronousNonBlocking ? html`<span>@AsynchronousNonBlocking</span>` : html``} | ||
${guardedMethod.Blocking ? html`<span>@Blocking</span>` : html``} | ||
${guardedMethod.NonBlocking ? html`<span>@NonBlocking</span>` : html``} | ||
${guardedMethod.Bulkhead ? this._renderBulkhead(guardedMethod.Bulkhead) : html``} | ||
${guardedMethod.CircuitBreaker ? this._renderCircuitBreaker(guardedMethod.CircuitBreaker) : html``} | ||
${guardedMethod.CircuitBreakerName ? this._renderCircuitBreakerName(guardedMethod.CircuitBreakerName) : html``} | ||
${guardedMethod.Fallback ? this._renderFallback(guardedMethod.Fallback) : html``} | ||
${guardedMethod.RateLimit ? this._renderRateLimit(guardedMethod.RateLimit) : html``} | ||
${guardedMethod.Retry ? this._renderRetry(guardedMethod.Retry) : html``} | ||
${guardedMethod.ExponentialBackoff ? this._renderExponentialBackoff(guardedMethod.ExponentialBackoff) : html``} | ||
${guardedMethod.FibonacciBackoff ? this._renderFibonacciBackoff(guardedMethod.FibonacciBackoff) : html``} | ||
${guardedMethod.CustomBackoff ? this._renderCustomBackoff(guardedMethod.CustomBackoff) : html``} | ||
${guardedMethod.Timeout ? this._renderTimeout(guardedMethod.Timeout) : html``} | ||
</vaadin-vertical-layout> | ||
`; | ||
} | ||
|
||
_renderApplyFaultTolerance(applyFaultTolerance) { | ||
return html` | ||
<span>@ApplyFaultTolerance("${applyFaultTolerance.value}")</span> | ||
`; | ||
} | ||
|
||
_renderBulkhead(bulkhead) { | ||
return html` | ||
<span>@Bulkhead(value = ${bulkhead.value}, waitingTaskQueue = ${bulkhead.waitingTaskQueue})</span> | ||
`; | ||
} | ||
|
||
_renderCircuitBreaker(circuitBreaker) { | ||
return html` | ||
<span>@CircuitBreaker(delay = ${circuitBreaker.delay} ${circuitBreaker.delayUnit}, | ||
requestVolumeThreshold = ${circuitBreaker.requestVolumeThreshold}, | ||
failureRatio = ${circuitBreaker.failureRatio}, | ||
successThreshold = ${circuitBreaker.successThreshold}, | ||
failOn = ${this._renderArray(circuitBreaker.failOn)}, | ||
skipOn = ${this._renderArray(circuitBreaker.skipOn)})</span> | ||
`; | ||
} | ||
|
||
_renderCircuitBreakerName(circuitBreakerName) { | ||
return html` | ||
<span> | ||
↪ | ||
@CircuitBreakerName("${circuitBreakerName.value}") | ||
</span> | ||
`; | ||
} | ||
|
||
_renderFallback(fallback) { | ||
return html` | ||
<span>@Fallback(value = ${fallback.value}, | ||
fallbackMethod = "${fallback.fallbackMethod}", | ||
applyOn = ${this._renderArray(fallback.applyOn)}, | ||
skipOn = ${this._renderArray(fallback.skipOn)})</span> | ||
`; | ||
} | ||
|
||
_renderRateLimit(rateLimit) { | ||
return html` | ||
<span>@RateLimit(value = ${rateLimit.value}, | ||
window = ${rateLimit.window} ${rateLimit.windowUnit}, | ||
minSpacing = ${rateLimit.minSpacing} ${rateLimit.minSpacingUnit}, | ||
type = ${rateLimit.type})</span> | ||
`; | ||
} | ||
|
||
_renderRetry(retry) { | ||
return html` | ||
<span>@Retry(maxRetries = ${retry.maxRetries}, | ||
delay = ${retry.delay} ${retry.delayUnit}, | ||
maxDuration = ${retry.maxDuration} ${retry.maxDurationUnit}, | ||
jitter = ${retry.jitter} ${retry.jitterUnit}, | ||
retryOn = ${this._renderArray(retry.retryOn)}, | ||
abortOn = ${this._renderArray(retry.abortOn)})</span> | ||
`; | ||
} | ||
|
||
_renderExponentialBackoff(exponentialBackoff) { | ||
return html` | ||
<span> | ||
↪ | ||
@ExponentialBackoff(factor = ${exponentialBackoff.factor}, | ||
maxDelay = ${exponentialBackoff.maxDelay} ${exponentialBackoff.maxDelayUnit}) | ||
</span> | ||
`; | ||
} | ||
|
||
_renderFibonacciBackoff(fibonacciBackoff) { | ||
return html` | ||
<span> | ||
↪ | ||
@FibonacciBackoff(maxDelay = ${fibonacciBackoff.maxDelay} ${fibonacciBackoff.maxDelayUnit}) | ||
</span> | ||
`; | ||
} | ||
|
||
_renderCustomBackoff(customBackoff) { | ||
return html` | ||
<span> | ||
↪ | ||
@CustomBackoff(${customBackoff.value}) | ||
</span> | ||
`; | ||
} | ||
|
||
_renderTimeout(timeout) { | ||
return html` | ||
<span>@Timeout(${timeout.value} ${timeout.valueUnit})</span> | ||
`; | ||
} | ||
|
||
_renderArray(array) { | ||
return array ? html`[${array.join(', ')}]` : html`[]`; | ||
} | ||
|
||
_refresh() { | ||
this.jsonRpc.getGuardedMethods().then(guardedMethods => { | ||
this._guardedMethods = guardedMethods.result; | ||
}); | ||
} | ||
} | ||
|
||
customElements.define('qwc-fault-tolerance-methods', QwcFaultToleranceMethods); |
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
Oops, something went wrong.