Swift_Plugins_ThrottlerPlugin
extends Swift_Plugins_BandwidthMonitorPlugin
in package
implements
Swift_Plugins_Sleeper, Swift_Plugins_Timer
Throttles the rate at which emails are sent.
Tags
Interfaces, Classes and Traits
- Swift_Plugins_Sleeper
- Sleeps for a duration of time.
- Swift_Plugins_Timer
- Provides timestamp data.
Table of Contents
- BYTES_PER_MINUTE = 0x1
- Flag for throttling in bytes per minute
- MESSAGES_PER_MINUTE = 0x10
- Flag for throttling in emails per minute
- MESSAGES_PER_SECOND = 0x11
- Flag for throttling in emails per second (Amazon SES)
- $in : int
- The incoming traffic counter.
- $messages : int
- An internal counter of the number of messages sent.
- $mirrors : mixed
- Bound byte streams
- $mode : int
- The mode for throttling.
- $out : int
- The outgoing traffic counter.
- $rate : int
- The rate at which messages should be sent.
- $sleeper : Swift_Plugins_Sleeper
- The Sleeper instance for sleeping.
- $start : int
- The time at which the first email was sent.
- $timer : Swift_Plugins_Timer
- The Timer instance which provides the timestamp.
- __construct() : mixed
- Create a new ThrottlerPlugin.
- beforeSendPerformed() : mixed
- Invoked immediately before the Message is sent.
- bind() : mixed
- Attach $is to this stream.
- commandSent() : mixed
- Invoked immediately following a command being sent.
- commit() : mixed
- Not used.
- flushBuffers() : mixed
- Not used.
- getBytesIn() : int
- Get the total number of bytes received from the server.
- getBytesOut() : int
- Get the total number of bytes sent to the server.
- getTimestamp() : int
- Get the current UNIX timestamp.
- reset() : mixed
- Reset the internal counters to zero.
- responseReceived() : mixed
- Invoked immediately following a response coming back.
- sendPerformed() : mixed
- Invoked when a Message is sent.
- sleep() : mixed
- Sleep for $seconds.
- unbind() : mixed
- Remove an already bound stream.
- write() : int
- Called when a message is sent so that the outgoing counter can be increased.
- throttleBytesPerMinute() : int
- Get a number of seconds to sleep for.
- throttleMessagesPerMinute() : int
- Get a number of seconds to sleep for.
- throttleMessagesPerSecond() : int
- Get a number of seconds to sleep for.
Constants
BYTES_PER_MINUTE
Flag for throttling in bytes per minute
public
mixed
BYTES_PER_MINUTE
= 0x1
MESSAGES_PER_MINUTE
Flag for throttling in emails per minute
public
mixed
MESSAGES_PER_MINUTE
= 0x10
MESSAGES_PER_SECOND
Flag for throttling in emails per second (Amazon SES)
public
mixed
MESSAGES_PER_SECOND
= 0x11
Properties
$in
The incoming traffic counter.
private
int
$in
= 0
$messages
An internal counter of the number of messages sent.
private
int
$messages
= 0
$mirrors
Bound byte streams
private
mixed
$mirrors
= []
$mode
The mode for throttling.
private
int
$mode
$out
The outgoing traffic counter.
private
int
$out
= 0
$rate
The rate at which messages should be sent.
private
int
$rate
$sleeper
The Sleeper instance for sleeping.
private
Swift_Plugins_Sleeper
$sleeper
$start
The time at which the first email was sent.
private
int
$start
$timer
The Timer instance which provides the timestamp.
private
Swift_Plugins_Timer
$timer
Methods
__construct()
Create a new ThrottlerPlugin.
public
__construct(int $rate[, int $mode = self::BYTES_PER_MINUTE ][, Swift_Plugins_Sleeper $sleeper = null ][, Swift_Plugins_Timer $timer = null ]) : mixed
Parameters
- $rate : int
- $mode : int = self::BYTES_PER_MINUTE
-
- $sleeper : Swift_Plugins_Sleeper = null
-
(only needed in testing)
- $timer : Swift_Plugins_Timer = null
-
(only needed in testing)
Return values
mixed —beforeSendPerformed()
Invoked immediately before the Message is sent.
public
beforeSendPerformed(Swift_Events_SendEvent $evt) : mixed
Parameters
- $evt : Swift_Events_SendEvent
Return values
mixed —bind()
Attach $is to this stream.
public
bind(Swift_InputByteStream $is) : mixed
The stream acts as an observer, receiving all data that is written. All and operations will be mirrored.
Parameters
- $is : Swift_InputByteStream
Return values
mixed —commandSent()
Invoked immediately following a command being sent.
public
commandSent(Swift_Events_CommandEvent $evt) : mixed
Parameters
- $evt : Swift_Events_CommandEvent
Return values
mixed —commit()
Not used.
public
commit() : mixed
Return values
mixed —flushBuffers()
Not used.
public
flushBuffers() : mixed
Return values
mixed —getBytesIn()
Get the total number of bytes received from the server.
public
getBytesIn() : int
Return values
int —getBytesOut()
Get the total number of bytes sent to the server.
public
getBytesOut() : int
Return values
int —getTimestamp()
Get the current UNIX timestamp.
public
getTimestamp() : int
Return values
int —reset()
Reset the internal counters to zero.
public
reset() : mixed
Return values
mixed —responseReceived()
Invoked immediately following a response coming back.
public
responseReceived(Swift_Events_ResponseEvent $evt) : mixed
Parameters
- $evt : Swift_Events_ResponseEvent
Return values
mixed —sendPerformed()
Invoked when a Message is sent.
public
sendPerformed(Swift_Events_SendEvent $evt) : mixed
Parameters
- $evt : Swift_Events_SendEvent
Return values
mixed —sleep()
Sleep for $seconds.
public
sleep(int $seconds) : mixed
Parameters
- $seconds : int
Return values
mixed —unbind()
Remove an already bound stream.
public
unbind(Swift_InputByteStream $is) : mixed
If $is is not bound, no errors will be raised. If the stream currently has any buffered data it will be written to $is before unbinding occurs.
Parameters
- $is : Swift_InputByteStream
Return values
mixed —write()
Called when a message is sent so that the outgoing counter can be increased.
public
write(string $bytes) : int
Parameters
- $bytes : string
Return values
int —throttleBytesPerMinute()
Get a number of seconds to sleep for.
private
throttleBytesPerMinute(int $timePassed) : int
Parameters
- $timePassed : int
Return values
int —throttleMessagesPerMinute()
Get a number of seconds to sleep for.
private
throttleMessagesPerMinute(int $timePassed) : int
Parameters
- $timePassed : int
Return values
int —throttleMessagesPerSecond()
Get a number of seconds to sleep for.
private
throttleMessagesPerSecond(int $timePassed) : int
Parameters
- $timePassed : int