MySQL::Replication::Command - Encapsulation of MySQL::Replication IPC
my $Request = MySQL::Replication::Command->new( Command => 'GET', Headers => { Host => $Host, Binlog => $Binlog, StartLog => $StartLog, StartPos => $StartPos, }, ); $Request->SendToSocket( $Socket, NonBlocking => $NonBlocking, ); my $Response = MySQL::Replication::Command->NewFromSocket( Socket => $Socket, Buffer => $Buffer, NonBlocking => $NonBlocking, ); print $Response->Stringify();
MySQL::Replication::Command contains convenience methods to encapsulate MySQL::Replication interprocess communication.
my $Response = MySQL::Replication::Command->new( Command => 'QUERY', Headers => { Timestamp => $Timestamp, Database => $Database, Log => $Log, Pos => $Pos, Length => $Length, }, Body => $Body, );
new() creates a command.
If the return value was undef, inspect $MySQL::Replication::Command::Errstr for an error message.
undef
$MySQL::Replication::Command::Errstr
Command (mandatory)
The IPC command type. This parameter is mandatory.
Headers (optional)
The headers for the command.
Body (optional)
The body for the command.
The Length header field will be set to the length of Body if it wasn't provided.
Length
Body
my $Response = MySQL::Replication::Command->NewFromSocket( Socket => $Socket, Buffer => $Buffer, NonBlocking => $NonBlocking, );
NewFromSocket() reads a command from the socket.
Socket (mandatory)
The socket to read from.
Buffer (mandatory)
A reference to the read buffer.
NonBlocking (optional, default false)
A boolean specifying that reading from the socket is non-blocking.
If NonBlocking is false, then the call will block until the read is complete.
NonBlocking
If NonBlocking is true, then the call will return undef if the read would have blocked (indicating to try again later).
$Request->SendToSocket( $Socket, NonBlocking => $NonBlocking, );
SendToSocket() writes the command to the socket.
$Socket (mandatory)
The socket to write to.
NonBlocking (optional, default: false)
A boolean specifying that writing to the socket is non-blocking.
If NonBlocking is false, then the call will block until the write is complete.
If NonBlocking is true, then the call will return undef if the write would have blocked (indicating to try again later).
print $Response->Stringify();
Stringify() returns the stringification of the command. This is what gets written to the socket in SendToSocket().
Please report any bugs or feature requests to bug-mysql-replication at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MySQL-Replication.
bug-mysql-replication at rt.cpan.org
Alfie John, alfiej at opera.com
alfiej at opera.com
Copyright (c) 2011, Opera Software Australia Pty. Ltd. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To install MySQL::Replication, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MySQL::Replication
CPAN shell
perl -MCPAN -e shell install MySQL::Replication
For more information on module installation, please visit the detailed CPAN module installation guide.