Class FcCommand<T>
java.lang.Object
org.frontcache.resilience.FcCommand<T>
- Direct Known Subclasses:
FC_BypassCache, FC_ThroughCache, FC_ThroughCache_HttpClient, FC_ThroughCache_WebFilter, FC_Total
The seam. Reproduces the slice of the
HystrixCommand contract Frontcache's five commands
actually use, on top of Resilience4j.
The five commands consume exactly five things from Hystrix: the Setter chain in the
constructor, run(), getFallback(), getExecutionEvents(),
getFailedExecutionException() and execute(). That uniformity is what makes this
migration a base-class swap rather than a rewrite - see proposal sections 3.1 and 4.
Two behavioral details are preserved deliberately, because getting either wrong would be a silent
production change:
- getFailedExecutionException() is populated only for a genuine FAILURE, and stays null for
TIMEOUT / SHORT_CIRCUITED / rejections, exactly as Hystrix does. The existing fallbacks depend on
it: FC_ThroughCache_HttpClient's log line passes it to SLF4J as the throwable, and expects a null
there for a timeout so it logs a message without a stack trace.
- getFallback() is invoked from the catch block below, on the calling thread, with no
reactive subscription in between - so it always runs. That is the fix for the "in multi threaded
environment hystrix does not resolve fallback ??" comment in ConcurrentIncludeProcessor
(section 6.4).
An FcBadRequestException is rethrown to the caller without resolving a fallback and without
moving the circuit breaker's failure rate, matching HystrixBadRequestException.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMirrorsHystrixCommand.Setterso the constructor bodies of the five commands change by one type name and nothing else. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
FcCommand
-
-
Method Details
-
run
-
getFallback
Overridden by every Frontcache command. The base implementation signals "no fallback available", whichexecute()turns into anFcCommandException- the HystrixRuntimeException equivalent. -
getExecutionDescription
What the watchdog names in its log line. Overridable so a command can add the URL it is on. -
execute
-
getExecutionEvents
The events of this execution, in the order they happened. Read inside getFallback() by four of the five commands (viaFallbackLogger.failureType(List)), so the failure event is already recorded by the time the fallback runs. -
getFailedExecutionException
Null unless run() itself threw - see the class javadoc. -
getCommandKey
-
getGroupKey
-