MediaWiki REL1_35
PoolCounterWorkViaCallback Class Reference

Convenience class for dealing with PoolCounters using callbacks. More...

Inheritance diagram for PoolCounterWorkViaCallback:
Collaboration diagram for PoolCounterWorkViaCallback:

Public Member Functions

 __construct ( $type, $key, array $callbacks)
 Build a PoolCounterWork class from a type, key, and callback map.
 
 doWork ()
 Actually perform the work, caching it if needed.
 
 error ( $status)
 Do something with the error, like showing it to the user.
 
 fallback ( $fast)
 A work not so good (eg.
 
 getCachedWork ()
 Retrieve the work from cache.
 
- Public Member Functions inherited from PoolCounterWork
 __construct (string $type, string $key, PoolCounter $poolCounter=null)
 
 execute ( $skipcache=false)
 Get the result of the work (whatever it is), or the result of the error() function.
 
 logError ( $status)
 Log an error.
 

Protected Attributes

callable null $doCachedWork
 
callable $doWork
 
callable null $error
 
callable null $fallback
 
- Protected Attributes inherited from PoolCounterWork
bool $cacheable = false
 
string $type = 'generic'
 

Additional Inherited Members

- Protected Member Functions inherited from PoolCounterWork
 isFastStaleEnabled ()
 Should fast stale mode be used?
 

Detailed Description

Convenience class for dealing with PoolCounters using callbacks.

Since
1.22 @newable
Note
marked as newable in 1.35 for lack of a better alternative, but should use a factory in the future.

Definition at line 31 of file PoolCounterWorkViaCallback.php.

Constructor & Destructor Documentation

◆ __construct()

PoolCounterWorkViaCallback::__construct (   $type,
  $key,
array  $callbacks 
)

Build a PoolCounterWork class from a type, key, and callback map.

The callback map must at least have a callback for the 'doWork' method. Additionally, callbacks can be provided for the 'doCachedWork', 'fallback', and 'error' methods. Methods without callbacks will be no-ops that return false. If a 'doCachedWork' callback is provided, then execute() may wait for any prior process in the pool to finish and reuse its cached result.

Stable to call

Parameters
string$typeThe class of actions to limit concurrency for
string$key
array$callbacksMap of callbacks
Exceptions
MWException

Definition at line 57 of file PoolCounterWorkViaCallback.php.

References PoolCounterWork\$type, and doWork().

Member Function Documentation

◆ doWork()

PoolCounterWorkViaCallback::doWork ( )

Actually perform the work, caching it if needed.

Returns
mixed Work result or false

Reimplemented from PoolCounterWork.

Definition at line 73 of file PoolCounterWorkViaCallback.php.

References doWork().

Referenced by __construct(), and doWork().

◆ error()

PoolCounterWorkViaCallback::error (   $status)

Do something with the error, like showing it to the user.

Parameters
Status$status
Returns
bool

Reimplemented from PoolCounterWork.

Definition at line 91 of file PoolCounterWorkViaCallback.php.

References error().

Referenced by error().

◆ fallback()

PoolCounterWorkViaCallback::fallback (   $fast)

A work not so good (eg.

expired one) but better than an error message.

Parameters
bool$fastTrue if PoolCounter is requesting a fast stale response (pre-wait)
Returns
mixed Work result or false

Reimplemented from PoolCounterWork.

Definition at line 84 of file PoolCounterWorkViaCallback.php.

References fallback().

Referenced by fallback().

◆ getCachedWork()

PoolCounterWorkViaCallback::getCachedWork ( )

Retrieve the work from cache.

Returns
mixed Work result or false

Reimplemented from PoolCounterWork.

Definition at line 77 of file PoolCounterWorkViaCallback.php.

Member Data Documentation

◆ $doCachedWork

callable null PoolCounterWorkViaCallback::$doCachedWork
protected

Definition at line 35 of file PoolCounterWorkViaCallback.php.

◆ $doWork

callable PoolCounterWorkViaCallback::$doWork
protected

Definition at line 33 of file PoolCounterWorkViaCallback.php.

◆ $error

callable null PoolCounterWorkViaCallback::$error
protected

Definition at line 39 of file PoolCounterWorkViaCallback.php.

◆ $fallback

callable null PoolCounterWorkViaCallback::$fallback
protected

Definition at line 37 of file PoolCounterWorkViaCallback.php.


The documentation for this class was generated from the following file: