PHP Класс Odesk\Phystrix\AbstractCommand

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$commandKey string Command Key, used for grouping Circuit Breakers
$config Zend\Config\Config Command configuration
$serviceLocator Zend\Di\LocatorInterface

Открытые методы

Метод Описание
execute ( ) : mixed Executes the command Isolation and fault tolerance logic (Circuit Breaker) is built-in
getCommandKey ( ) : string Determines and returns command key, used for circuit breaker grouping and metrics tracking
getExecutionEvents ( ) : array Returns events collected
getExecutionException ( ) : Exceptio\Exception | null Returns exception thrown while executing the command, if there was any
getExecutionTimeInMilliseconds ( ) : null | integer Returns execution time in milliseconds, null if not executed
initializeConfig ( Zend\Config\Config $phystrixConfig ) Sets base command configuration from the global phystrix configuration
setCircuitBreakerFactory ( Odesk\Phystrix\CircuitBreakerFactory $circuitBreakerFactory ) Sets instance of circuit breaker factory
setCommandMetricsFactory ( Odesk\Phystrix\CommandMetricsFactory $commandMetricsFactory ) Sets instance of command metrics factory
setConfig ( Zend\Config\Config $config, boolean $merge = true ) Sets configuration for the command, allows to override config in runtime
setRequestCache ( RequestCache $requestCache ) Sets shared object for request caching
setRequestLog ( Odesk\Phystrix\RequestLog $requestLog ) Sets shared object for request logging
setServiceLocator ( Zend\Di\LocatorInterface $serviceLocator ) Sets service locator instance, for injecting custom dependencies into the command

Защищенные методы

Метод Описание
getCacheKey ( ) : string | null Key to be used for request caching.
getFallback ( ) Code for when execution fails for whatever reason
prepare ( ) Custom preparation logic, preceding command execution
processExecutionEvent ( string $eventName ) Custom logic proceeding event generation
run ( ) : mixed The code to be executed

Приватные методы

Метод Описание
getCircuitBreaker ( ) : Odesk\Phystrix\CircuitBreaker Circuit breaker for this command key
getFallbackOrThrowException ( Exception $originalException = null ) : mixed Attempts to retrieve fallback by calling getFallback
getMetrics ( ) : Odesk\Phystrix\CommandMetrics Command Metrics for this command key
getTimeInMilliseconds ( ) : float Returns current time on the server in milliseconds
isRequestCacheEnabled ( ) : boolean Determines whether request caching is enabled for this command
recordExecutedCommand ( ) Adds reference to the command to the current request log
recordExecutionEvent ( string $eventName ) Logic to record events and exceptions as they take place
recordExecutionTime ( ) Records command execution time if the command was executed, not short-circuited and not returned from cache

Описание методов

execute() публичный Метод

Executes the command Isolation and fault tolerance logic (Circuit Breaker) is built-in
public execute ( ) : mixed
Результат mixed

getCacheKey() защищенный Метод

By default this return null, which means "do not cache". To enable caching, override this method and return a string key uniquely representing the state of a command instance. If multiple command instances are executed within current HTTP request, only the first one will be executed and all others returned from cache.
protected getCacheKey ( ) : string | null
Результат string | null

getCommandKey() публичный Метод

Determines and returns command key, used for circuit breaker grouping and metrics tracking
public getCommandKey ( ) : string
Результат string

getExecutionEvents() публичный Метод

Returns events collected
public getExecutionEvents ( ) : array
Результат array

getExecutionException() публичный Метод

Returns exception thrown while executing the command, if there was any
public getExecutionException ( ) : Exceptio\Exception | null
Результат Exceptio\Exception | null

getExecutionTimeInMilliseconds() публичный Метод

Returns execution time in milliseconds, null if not executed
public getExecutionTimeInMilliseconds ( ) : null | integer
Результат null | integer

getFallback() защищенный Метод

Code for when execution fails for whatever reason
protected getFallback ( )

initializeConfig() публичный Метод

Sets base command configuration from the global phystrix configuration
public initializeConfig ( Zend\Config\Config $phystrixConfig )
$phystrixConfig Zend\Config\Config

prepare() защищенный Метод

Custom preparation logic, preceding command execution
protected prepare ( )

processExecutionEvent() защищенный Метод

Custom logic proceeding event generation
protected processExecutionEvent ( string $eventName )
$eventName string

run() абстрактный защищенный Метод

The code to be executed
abstract protected run ( ) : mixed
Результат mixed

setCircuitBreakerFactory() публичный Метод

Sets instance of circuit breaker factory
public setCircuitBreakerFactory ( Odesk\Phystrix\CircuitBreakerFactory $circuitBreakerFactory )
$circuitBreakerFactory Odesk\Phystrix\CircuitBreakerFactory

setCommandMetricsFactory() публичный Метод

Sets instance of command metrics factory
public setCommandMetricsFactory ( Odesk\Phystrix\CommandMetricsFactory $commandMetricsFactory )
$commandMetricsFactory Odesk\Phystrix\CommandMetricsFactory

setConfig() публичный Метод

Sets configuration for the command, allows to override config in runtime
public setConfig ( Zend\Config\Config $config, boolean $merge = true )
$config Zend\Config\Config
$merge boolean

setRequestCache() публичный Метод

Sets shared object for request caching
public setRequestCache ( RequestCache $requestCache )
$requestCache RequestCache

setRequestLog() публичный Метод

Sets shared object for request logging
public setRequestLog ( Odesk\Phystrix\RequestLog $requestLog )
$requestLog Odesk\Phystrix\RequestLog

setServiceLocator() публичный Метод

Sets service locator instance, for injecting custom dependencies into the command
public setServiceLocator ( Zend\Di\LocatorInterface $serviceLocator )
$serviceLocator Zend\Di\LocatorInterface

Описание свойств

$commandKey защищенное свойство

Command Key, used for grouping Circuit Breakers
protected string $commandKey
Результат string

$config защищенное свойство

Command configuration
protected Config,Zend\Config $config
Результат Zend\Config\Config

$serviceLocator защищенное свойство

protected LocatorInterface,Zend\Di $serviceLocator
Результат Zend\Di\LocatorInterface