SquidPurgeClient Class Reference

An HTTP 1.0 client built for the purposes of purging Squid and Varnish. More...

List of all members.

Public Member Functions

 __construct ($server, $options=array())
 getReadSocketsForSelect ()
 Get read socket array for select().
 getWriteSocketsForSelect ()
 Get write socket array for select().
 close ()
 Close the socket but allow it to be reopened for future purge requests.
 queuePurge ($url)
 Queue a purge operation.
 isIdle ()
 doWrites ()
 Perform pending writes.
 doReads ()
 Read some data.

Public Attributes

 $host
 $port
 $ip
 $readState = 'idle'
 $writeBuffer = ''
 $requests = array()
 $currentRequestIndex
const EINTR = 4
const EAGAIN = 11
const EINPROGRESS = 115
const BUFFER_SIZE = 8192
 $socket
 The socket resource, or null for unconnected, or false for disabled due to error.

Protected Member Functions

 getSocket ()
 Open a socket if there isn't one open already, return it.
 getIP ()
 Get the host's IP address.
 markDown ()
 Close the socket and ignore any future purge requests.
 processReadBuffer ()
 processStatusLine ($line)
 processHeaderLine ($line)
 nextRequest ()
 log ($msg)


Detailed Description

An HTTP 1.0 client built for the purposes of purging Squid and Varnish.

Uses asynchronous I/O, allowing purges to be done in a highly parallel manner.

Could be replaced by curl_multi_exec() or some such.

Definition at line 9 of file SquidPurgeClient.php.


Constructor & Destructor Documentation

SquidPurgeClient::__construct ( server,
options = array() 
)

Definition at line 27 of file SquidPurgeClient.php.


Member Function Documentation

SquidPurgeClient::close (  ) 

Close the socket but allow it to be reopened for future purge requests.

Definition at line 127 of file SquidPurgeClient.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by doReads(), and markDown().

SquidPurgeClient::doReads (  ) 

Read some data.

Call this when socket_select() indicates that the read buffer is non-empty.

Definition at line 196 of file SquidPurgeClient.php.

References $socket, close(), getSocket(), log(), markDown(), processReadBuffer(), wfRestoreWarnings(), and wfSuppressWarnings().

SquidPurgeClient::doWrites (  ) 

Perform pending writes.

Call this when socket_select() indicates that writing will not block.

Definition at line 161 of file SquidPurgeClient.php.

References $socket, getSocket(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().

SquidPurgeClient::getIP (  )  [protected]

Get the host's IP address.

Does not support IPv6 at present due to the lack of a convenient interface in PHP.

Definition at line 97 of file SquidPurgeClient.php.

References IP::isIPv4(), IP::isIPv6(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by getSocket().

SquidPurgeClient::getReadSocketsForSelect (  ) 

Get read socket array for select().

Definition at line 68 of file SquidPurgeClient.php.

References $socket, and getSocket().

SquidPurgeClient::getSocket (  )  [protected]

Open a socket if there isn't one open already, return it.

Returns false on error.

Definition at line 37 of file SquidPurgeClient.php.

References $ip, $ok, getIP(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().

SquidPurgeClient::getWriteSocketsForSelect (  ) 

Get write socket array for select().

Definition at line 82 of file SquidPurgeClient.php.

References $socket, and getSocket().

SquidPurgeClient::isIdle (  ) 

Definition at line 154 of file SquidPurgeClient.php.

SquidPurgeClient::log ( msg  )  [protected]

Definition at line 302 of file SquidPurgeClient.php.

References wfDebugLog().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

SquidPurgeClient::markDown (  )  [protected]

Close the socket and ignore any future purge requests.

This is called if there is a protocol error.

Definition at line 119 of file SquidPurgeClient.php.

References close().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

SquidPurgeClient::nextRequest (  )  [protected]

Definition at line 286 of file SquidPurgeClient.php.

Referenced by processReadBuffer(), and queuePurge().

SquidPurgeClient::processHeaderLine ( line  )  [protected]

Definition at line 278 of file SquidPurgeClient.php.

Referenced by processReadBuffer().

SquidPurgeClient::processReadBuffer (  )  [protected]

Definition at line 223 of file SquidPurgeClient.php.

References nextRequest(), processHeaderLine(), and processStatusLine().

Referenced by doReads().

SquidPurgeClient::processStatusLine ( line  )  [protected]

Definition at line 262 of file SquidPurgeClient.php.

References log(), and markDown().

Referenced by processReadBuffer().

SquidPurgeClient::queuePurge ( url  ) 

Queue a purge operation.

Definition at line 143 of file SquidPurgeClient.php.

References $url, nextRequest(), and Http::userAgent().


Member Data Documentation

SquidPurgeClient::$currentRequestIndex

Definition at line 15 of file SquidPurgeClient.php.

SquidPurgeClient::$host

Definition at line 10 of file SquidPurgeClient.php.

SquidPurgeClient::$ip

Definition at line 10 of file SquidPurgeClient.php.

Referenced by getSocket().

SquidPurgeClient::$port

Definition at line 10 of file SquidPurgeClient.php.

SquidPurgeClient::$readState = 'idle'

Definition at line 12 of file SquidPurgeClient.php.

SquidPurgeClient::$requests = array()

Definition at line 14 of file SquidPurgeClient.php.

SquidPurgeClient::$socket

The socket resource, or null for unconnected, or false for disabled due to error.

Definition at line 25 of file SquidPurgeClient.php.

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().

SquidPurgeClient::$writeBuffer = ''

Definition at line 13 of file SquidPurgeClient.php.

Definition at line 20 of file SquidPurgeClient.php.

Definition at line 18 of file SquidPurgeClient.php.

Definition at line 19 of file SquidPurgeClient.php.

Definition at line 17 of file SquidPurgeClient.php.


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

Generated on Sat Apr 30 22:57:50 2011 for MediaWiki by  doxygen 1.5.9