XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
Swift_Plugins_ThrottlerPlugin Class Reference
Inheritance diagram for Swift_Plugins_ThrottlerPlugin:
Inheritance graph

Public Member Functions

 __construct ($rate, $mode=self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper=null, Swift_Plugins_Timer $timer=null)
 
 beforeSendPerformed (Swift_Events_SendEvent $evt)
 
 getTimestamp ()
 
 sendPerformed (Swift_Events_SendEvent $evt)
 
 sleep ($seconds)
 
- Public Member Functions inherited from Swift_Plugins_BandwidthMonitorPlugin
 beforeSendPerformed (Swift_Events_SendEvent $evt)
 
 bind (Swift_InputByteStream $is)
 
 commandSent (Swift_Events_CommandEvent $evt)
 
 commit ()
 
 flushBuffers ()
 
 getBytesIn ()
 
 getBytesOut ()
 
 reset ()
 
 responseReceived (Swift_Events_ResponseEvent $evt)
 
 sendPerformed (Swift_Events_SendEvent $evt)
 
 unbind (Swift_InputByteStream $is)
 
 write ($bytes)
 

Public Attributes

const BYTES_PER_MINUTE = 0x01
 
const MESSAGES_PER_MINUTE = 0x10
 

Private Member Functions

 _throttleBytesPerMinute ($timePassed)
 
 _throttleMessagesPerMinute ($timePassed)
 

Private Attributes

 $_messages = 0
 
 $_mode
 
 $_rate
 
 $_sleeper
 
 $_start
 
 $_timer
 

Detailed Description

Definition at line 22 of file ThrottlerPlugin.php.

Constructor & Destructor Documentation

Swift_Plugins_ThrottlerPlugin::__construct (   $rate,
  $mode = self::BYTES_PER_MINUTE,
Swift_Plugins_Sleeper  $sleeper = null,
Swift_Plugins_Timer  $timer = null 
)

Create a new ThrottlerPlugin.

Parameters
int$rate
int$mode,defaultsto BYTES_PER_MINUTE
Swift_Plugins_Sleeper$sleeper(only needed in testing)
Swift_Plugins_Timer$timer(only needed in testing)

Definition at line 83 of file ThrottlerPlugin.php.

Member Function Documentation

Swift_Plugins_ThrottlerPlugin::_throttleBytesPerMinute (   $timePassed)
private

Get a number of seconds to sleep for.

Parameters
int$timePassed
Returns
int private

Definition at line 170 of file ThrottlerPlugin.php.

References Swift_Plugins_BandwidthMonitorPlugin\getBytesOut().

Referenced by beforeSendPerformed().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_Plugins_ThrottlerPlugin::_throttleMessagesPerMinute (   $timePassed)
private

Get a number of seconds to sleep for.

Parameters
int$timePassed
Returns
int private

Definition at line 182 of file ThrottlerPlugin.php.

Referenced by beforeSendPerformed().

Here is the caller graph for this function:

Swift_Plugins_ThrottlerPlugin::beforeSendPerformed ( Swift_Events_SendEvent  $evt)

Invoked immediately before the Message is sent.

Parameters
Swift_Events_SendEvent$evt

Implements Swift_Events_SendListener.

Definition at line 96 of file ThrottlerPlugin.php.

References $_start, _throttleBytesPerMinute(), _throttleMessagesPerMinute(), getTimestamp(), and sleep().

Here is the call graph for this function:

Swift_Plugins_ThrottlerPlugin::getTimestamp ( )

Get the current UNIX timestamp

Returns
int

Implements Swift_Plugins_Timer.

Definition at line 150 of file ThrottlerPlugin.php.

Referenced by beforeSendPerformed().

Here is the caller graph for this function:

Swift_Plugins_ThrottlerPlugin::sendPerformed ( Swift_Events_SendEvent  $evt)

Invoked when a Message is sent.

Parameters
Swift_Events_SendEvent$evt

Implements Swift_Events_SendListener.

Definition at line 124 of file ThrottlerPlugin.php.

References $_messages.

Swift_Plugins_ThrottlerPlugin::sleep (   $seconds)

Sleep for $seconds.

Parameters
int$seconds

Implements Swift_Plugins_Sleeper.

Definition at line 134 of file ThrottlerPlugin.php.

Referenced by beforeSendPerformed().

Here is the caller graph for this function:

Member Data Documentation

Swift_Plugins_ThrottlerPlugin::$_messages = 0
private

Definition at line 74 of file ThrottlerPlugin.php.

Referenced by sendPerformed().

Swift_Plugins_ThrottlerPlugin::$_mode
private

Definition at line 67 of file ThrottlerPlugin.php.

Swift_Plugins_ThrottlerPlugin::$_rate
private

Definition at line 59 of file ThrottlerPlugin.php.

Swift_Plugins_ThrottlerPlugin::$_sleeper
private

Definition at line 38 of file ThrottlerPlugin.php.

Swift_Plugins_ThrottlerPlugin::$_start
private

Definition at line 52 of file ThrottlerPlugin.php.

Referenced by beforeSendPerformed().

Swift_Plugins_ThrottlerPlugin::$_timer
private

Definition at line 45 of file ThrottlerPlugin.php.

const Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE = 0x01

Flag for throttling in bytes per minute

Definition at line 28 of file ThrottlerPlugin.php.

const Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE = 0x10

Flag for throttling in emails per minute

Definition at line 31 of file ThrottlerPlugin.php.


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