Table of Contents

Class AbstractCommand<TResult>

Namespace
Steeltoe.CircuitBreaker.Hystrix
Assembly
Steeltoe.CircuitBreaker.HystrixBase.dll
public abstract class AbstractCommand<TResult> : AbstractCommandBase, IHystrixInvokableInfo, IHystrixInvokable

Type Parameters

TResult
Inheritance
AbstractCommand<TResult>
Implements
Derived
Inherited Members

Constructors

AbstractCommand(IHystrixCommandGroupKey, IHystrixCommandKey, IHystrixThreadPoolKey, IHystrixCircuitBreaker, IHystrixThreadPool, IHystrixCommandOptions, IHystrixThreadPoolOptions, HystrixCommandMetrics, SemaphoreSlim, SemaphoreSlim, HystrixOptionsStrategy, HystrixCommandExecutionHook, ILogger)

protected AbstractCommand(IHystrixCommandGroupKey group, IHystrixCommandKey key, IHystrixThreadPoolKey threadPoolKey, IHystrixCircuitBreaker circuitBreaker, IHystrixThreadPool threadPool, IHystrixCommandOptions commandOptionsDefaults, IHystrixThreadPoolOptions threadPoolOptionsDefaults, HystrixCommandMetrics metrics, SemaphoreSlim fallbackSemaphore, SemaphoreSlim executionSemaphore, HystrixOptionsStrategy optionsStrategy, HystrixCommandExecutionHook executionHook, ILogger logger = null)

Parameters

group IHystrixCommandGroupKey
key IHystrixCommandKey
threadPoolKey IHystrixThreadPoolKey
circuitBreaker IHystrixCircuitBreaker
threadPool IHystrixThreadPool
commandOptionsDefaults IHystrixCommandOptions
threadPoolOptionsDefaults IHystrixThreadPoolOptions
metrics HystrixCommandMetrics
fallbackSemaphore SemaphoreSlim
executionSemaphore SemaphoreSlim
optionsStrategy HystrixOptionsStrategy
executionHook HystrixCommandExecutionHook
logger ILogger

Fields

_circuitBreaker

protected readonly IHystrixCircuitBreaker _circuitBreaker

Field Value

IHystrixCircuitBreaker

_commandStartTimestamp

protected long _commandStartTimestamp

Field Value

long

_concurrencyStrategy

protected readonly HystrixConcurrencyStrategy _concurrencyStrategy

Field Value

HystrixConcurrencyStrategy

_currentRequestLog

protected readonly HystrixRequestLog _currentRequestLog

Field Value

HystrixRequestLog

_eventNotifier

protected readonly HystrixEventNotifier _eventNotifier

Field Value

HystrixEventNotifier

_execThreadTask

protected Task _execThreadTask

Field Value

Task

_executionHook

protected readonly HystrixCommandExecutionHook _executionHook

Field Value

HystrixCommandExecutionHook

_executionResult

protected volatile ExecutionResult _executionResult

Field Value

ExecutionResult

_executionResultAtTimeOfCancellation

protected volatile ExecutionResult _executionResultAtTimeOfCancellation

Field Value

ExecutionResult

_executionSemaphoreOverride

protected readonly SemaphoreSlim _executionSemaphoreOverride

Field Value

SemaphoreSlim

_fallbackSemaphoreOverride

protected readonly SemaphoreSlim _fallbackSemaphoreOverride

Field Value

SemaphoreSlim

_isFallbackUserDefined

protected bool _isFallbackUserDefined

Field Value

bool

_isResponseFromCache

protected volatile bool _isResponseFromCache

Field Value

bool

_metrics

protected readonly HystrixCommandMetrics _metrics

Field Value

HystrixCommandMetrics

_requestCache

protected readonly HystrixRequestCache _requestCache

Field Value

HystrixRequestCache

_threadPool

protected readonly IHystrixThreadPool _threadPool

Field Value

IHystrixThreadPool

_threadStartTimestamp

protected long _threadStartTimestamp

Field Value

long

_timeoutTcs

protected CancellationTokenSource _timeoutTcs

Field Value

CancellationTokenSource

_token

protected CancellationToken _token

Field Value

CancellationToken

_usersToken

protected CancellationToken _usersToken

Field Value

CancellationToken

commandGroup

protected readonly IHystrixCommandGroupKey commandGroup

Field Value

IHystrixCommandGroupKey

commandKey

protected readonly IHystrixCommandKey commandKey

Field Value

IHystrixCommandKey

commandState

protected readonly AbstractCommand<TResult>.AtomicCommandState commandState

Field Value

AbstractCommand<TResult>.AtomicCommandState

isCommandTimedOut

protected readonly AbstractCommand<TResult>.AtomicTimedOutStatus isCommandTimedOut

Field Value

AbstractCommand<TResult>.AtomicTimedOutStatus

options

protected readonly IHystrixCommandOptions options

Field Value

IHystrixCommandOptions

tcs

protected AbstractCommand<TResult>.HystrixCompletionSource tcs

Field Value

AbstractCommand<TResult>.HystrixCompletionSource

threadPoolKey

protected readonly IHystrixThreadPoolKey threadPoolKey

Field Value

IHystrixThreadPoolKey

threadState

protected readonly AbstractCommand<TResult>.AtomicThreadState threadState

Field Value

AbstractCommand<TResult>.AtomicThreadState

Properties

CacheKey

protected virtual string CacheKey { get; }

Property Value

string

CommandGroup

public IHystrixCommandGroupKey CommandGroup { get; }

Property Value

IHystrixCommandGroupKey

CommandIsScalar

protected virtual bool CommandIsScalar { get; }

Property Value

bool

CommandKey

public IHystrixCommandKey CommandKey { get; }

Property Value

IHystrixCommandKey

CommandOptions

public IHystrixCommandOptions CommandOptions { get; }

Property Value

IHystrixCommandOptions

CommandResult

protected virtual ExecutionResult CommandResult { get; }

Property Value

ExecutionResult

CommandRunStartTimeInNanos

public long CommandRunStartTimeInNanos { get; }

Property Value

long

EventCounts

public ExecutionResult.EventCounts EventCounts { get; }

Property Value

ExecutionResult.EventCounts

ExecutionEvents

public List<HystrixEventType> ExecutionEvents { get; }

Property Value

List<HystrixEventType>

ExecutionException

public Exception ExecutionException { get; }

Property Value

Exception

ExecutionTimeInMilliseconds

public int ExecutionTimeInMilliseconds { get; }

Property Value

int

FailedExecutionException

public Exception FailedExecutionException { get; }

Property Value

Exception

IsCircuitBreakerOpen

public bool IsCircuitBreakerOpen { get; }

Property Value

bool

IsExecutedInThread

public bool IsExecutedInThread { get; }

Property Value

bool

IsExecutionComplete

public bool IsExecutionComplete { get; }

Property Value

bool

IsFailedExecution

public bool IsFailedExecution { get; }

Property Value

bool

IsFallbackUserDefined

public virtual bool IsFallbackUserDefined { get; set; }

Property Value

bool

IsRequestCachingEnabled

protected virtual bool IsRequestCachingEnabled { get; }

Property Value

bool

IsResponseFromCache

public bool IsResponseFromCache { get; }

Property Value

bool

IsResponseFromFallback

public bool IsResponseFromFallback { get; }

Property Value

bool

IsResponseRejected

public bool IsResponseRejected { get; }

Property Value

bool

IsResponseSemaphoreRejected

public bool IsResponseSemaphoreRejected { get; }

Property Value

bool

IsResponseShortCircuited

public bool IsResponseShortCircuited { get; }

Property Value

bool

IsResponseThreadPoolRejected

public bool IsResponseThreadPoolRejected { get; }

Property Value

bool

IsResponseTimedOut

public bool IsResponseTimedOut { get; }

Property Value

bool

IsSuccessfulExecution

public bool IsSuccessfulExecution { get; }

Property Value

bool

LogMessagePrefix

protected virtual string LogMessagePrefix { get; }

Property Value

string

Metrics

public HystrixCommandMetrics Metrics { get; }

Property Value

HystrixCommandMetrics

NumberCollapsed

public int NumberCollapsed { get; }

Property Value

int

NumberEmissions

public int NumberEmissions { get; }

Property Value

int

NumberFallbackEmissions

public int NumberFallbackEmissions { get; }

Property Value

int

OriginatingCollapserKey

public IHystrixCollapserKey OriginatingCollapserKey { get; }

Property Value

IHystrixCollapserKey

PublicCacheKey

public string PublicCacheKey { get; }

Property Value

string

ShouldOutputOnNextEvents

protected virtual bool ShouldOutputOnNextEvents { get; }

Property Value

bool

ThreadPoolKey

public IHystrixThreadPoolKey ThreadPoolKey { get; }

Property Value

IHystrixThreadPoolKey

Methods

ApplyHystrixSemantics()

protected void ApplyHystrixSemantics()

DecomposeException(Exception)

protected Exception DecomposeException(Exception e)

Parameters

e Exception

Returns

Exception

DoFallback()

protected abstract TResult DoFallback()

Returns

TResult

DoRun()

protected abstract TResult DoRun()

Returns

TResult

GetExecutionSemaphore()

protected SemaphoreSlim GetExecutionSemaphore()

Returns

SemaphoreSlim

GetFallbackSemaphore()

protected SemaphoreSlim GetFallbackSemaphore()

Returns

SemaphoreSlim

HandleCleanUpAfterResponseFromCache(bool)

protected virtual void HandleCleanUpAfterResponseFromCache(bool commandExecutionStarted)

Parameters

commandExecutionStarted bool

HandleCommandEnd(bool)

protected virtual void HandleCommandEnd(bool commandExecutionStarted)

Parameters

commandExecutionStarted bool

HandleThreadEnd()

protected virtual void HandleThreadEnd()

InitCircuitBreaker(bool, IHystrixCircuitBreaker, IHystrixCommandGroupKey, IHystrixCommandKey, IHystrixCommandOptions, HystrixCommandMetrics)

protected static IHystrixCircuitBreaker InitCircuitBreaker(bool enabled, IHystrixCircuitBreaker fromConstructor, IHystrixCommandGroupKey groupKey, IHystrixCommandKey commandKey, IHystrixCommandOptions properties, HystrixCommandMetrics metrics)

Parameters

enabled bool
fromConstructor IHystrixCircuitBreaker
groupKey IHystrixCommandGroupKey
commandKey IHystrixCommandKey
properties IHystrixCommandOptions
metrics HystrixCommandMetrics

Returns

IHystrixCircuitBreaker

InitCommandKey(IHystrixCommandKey, Type)

protected static IHystrixCommandKey InitCommandKey(IHystrixCommandKey fromConstructor, Type clazz)

Parameters

fromConstructor IHystrixCommandKey
clazz Type

Returns

IHystrixCommandKey

InitCommandOptions(IHystrixCommandKey, HystrixOptionsStrategy, IHystrixCommandOptions)

protected static IHystrixCommandOptions InitCommandOptions(IHystrixCommandKey commandKey, HystrixOptionsStrategy optionsStrategy, IHystrixCommandOptions commandOptionsDefault)

Parameters

commandKey IHystrixCommandKey
optionsStrategy HystrixOptionsStrategy
commandOptionsDefault IHystrixCommandOptions

Returns

IHystrixCommandOptions

InitExecutionHook(HystrixCommandExecutionHook)

protected static HystrixCommandExecutionHook InitExecutionHook(HystrixCommandExecutionHook fromConstructor)

Parameters

fromConstructor HystrixCommandExecutionHook

Returns

HystrixCommandExecutionHook

InitGroupKey(IHystrixCommandGroupKey)

protected static IHystrixCommandGroupKey InitGroupKey(IHystrixCommandGroupKey fromConstructor)

Parameters

fromConstructor IHystrixCommandGroupKey

Returns

IHystrixCommandGroupKey

InitMetrics(HystrixCommandMetrics, IHystrixCommandGroupKey, IHystrixThreadPoolKey, IHystrixCommandKey, IHystrixCommandOptions)

protected static HystrixCommandMetrics InitMetrics(HystrixCommandMetrics fromConstructor, IHystrixCommandGroupKey groupKey, IHystrixThreadPoolKey threadPoolKey, IHystrixCommandKey commandKey, IHystrixCommandOptions properties)

Parameters

fromConstructor HystrixCommandMetrics
groupKey IHystrixCommandGroupKey
threadPoolKey IHystrixThreadPoolKey
commandKey IHystrixCommandKey
properties IHystrixCommandOptions

Returns

HystrixCommandMetrics

InitRequestLog(bool)

protected static HystrixRequestLog InitRequestLog(bool enabled)

Parameters

enabled bool

Returns

HystrixRequestLog

InitThreadPool(IHystrixThreadPool, IHystrixThreadPoolKey, IHystrixThreadPoolOptions)

protected static IHystrixThreadPool InitThreadPool(IHystrixThreadPool fromConstructor, IHystrixThreadPoolKey threadPoolKey, IHystrixThreadPoolOptions threadPoolPropertiesDefaults)

Parameters

fromConstructor IHystrixThreadPool
threadPoolKey IHystrixThreadPoolKey
threadPoolPropertiesDefaults IHystrixThreadPoolOptions

Returns

IHystrixThreadPool

InitThreadPoolKey(IHystrixThreadPoolKey, IHystrixCommandGroupKey, string)

protected static IHystrixThreadPoolKey InitThreadPoolKey(IHystrixThreadPoolKey threadPoolKey, IHystrixCommandGroupKey groupKey, string threadPoolKeyOverride)

Parameters

threadPoolKey IHystrixThreadPoolKey
groupKey IHystrixCommandGroupKey
threadPoolKeyOverride string

Returns

IHystrixThreadPoolKey

PutInCacheIfAbsent(Task<TResult>, out Task<TResult>)

protected bool PutInCacheIfAbsent(Task<TResult> hystrixTask, out Task<TResult> fromCache)

Parameters

hystrixTask Task<TResult>
fromCache Task<TResult>

Returns

bool

Setup()

protected void Setup()

StartCommand()

protected void StartCommand()