vulcain-corejs
Version: 
Vulcain micro-service framework
99 lines (98 loc) • 3.08 kB
TypeScript
export declare enum EventType {
    SUCCESS = 0,
    SHORT_CIRCUITED = 1,
    SEMAPHORE_REJECTED = 2,
    TIMEOUT = 3,
    FAILURE = 4,
    FALLBACK_REJECTION = 5,
    FALLBACK_SUCCESS = 6,
    FALLBACK_FAILURE = 7,
    RESPONSE_FROM_CACHE = 8,
}
export declare enum FailureType {
    SHORTCIRCUIT = 0,
    REJECTED_SEMAPHORE_EXECUTION = 1,
    TIMEOUT = 2,
    COMMAND_EXCEPTION = 3,
    REJECTED_SEMAPHORE_FALLBACK = 4,
}
export declare class ExecutionResult {
    events: Array<EventType>;
    /**
           * Whether the response was returned successfully either by executing <code>run()</code> or from cache.
           *
           * @return bool
           */
    readonly isSuccessfulExecution: boolean;
    /**
     * Whether the <code>run()</code> resulted in a failure (exception).
     *
     * @return bool
     */
    readonly isFailedExecution: boolean;
    /**
     * Get the Throwable/Exception thrown that caused the failure.
     * <p>
     * If <code>IsFailedExecution { get == true</code> then this would represent the Exception thrown by the <code>run()</code> method.
     * <p>
     * If <code>IsFailedExecution { get == false</code> then this would return null.
     *
     * @return Throwable or null
     */
    failedExecutionException: any;
    /**
     * Whether the response received from was the result of some type of failure
     * and <code>Fallback { get</code> being called.
     *
     * @return bool
     */
    readonly isResponseFromFallback: boolean;
    /**
     * Whether the response received was the result of a timeout
     * and <code>Fallback { get</code> being called.
     *
     * @return bool
     */
    readonly isResponseTimedOut: boolean;
    /**
     * Whether the response received was a fallback as result of being
     * short-circuited (meaning <code>IsCircuitBreakerOpen { get == true</code>) and <code>Fallback { get</code> being called.
     *
     * @return bool
     */
    readonly isResponseShortCircuited: boolean;
    /**
     * Whether the response is from cache and <code>run()</code> was not invoked.
     *
     * @return bool
     */
    readonly isResponseFromCache: boolean;
    /**
     * Whether the response received was a fallback as result of being
     * rejected (from thread-pool or semaphore) and <code>Fallback { get</code> being called.
     *
     * @return bool
     */
    readonly isResponseRejected: boolean;
    /**
     * List of CommandEventType enums representing events that occurred during execution.
     * <p>
     * Examples of events are SUCCESS, FAILURE, TIMEOUT, and SHORT_CIRCUITED
     *
     * @return {@code List<EventType>}
     */
    readonly executionEvents: EventType[];
    /**
     * The execution time of this command instance in milliseconds, or -1 if not executed.
     *
     * @return int
     */
    executionTime: number;
    /**
    * If this command has completed execution either successfully, via fallback or failure.
    *
    */
    isExecutionComplete: boolean;
    addEvent(evt: EventType): void;
    protected eventExists(evt: EventType): boolean;
}