NAME
MySQL::Replication::Command - Encapsulation of MySQL::Replication IPC
SYNOPSIS
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();
DESCRIPTION
MySQL::Replication::Command contains convenience methods to encapsulate MySQL::Replication interprocess communication.
METHODS
new
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.
Parameters
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 ofBody
if it wasn't provided.
NewFromSocket
my $Response = MySQL::Replication::Command->NewFromSocket(
Socket => $Socket,
Buffer => $Buffer,
NonBlocking => $NonBlocking,
);
NewFromSocket() reads a command from the socket.
If the return value was undef
, inspect $MySQL::Replication::Command::Errstr
for an error message.
Parameters
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.If
NonBlocking
is true, then the call will returnundef
if the read would have blocked (indicating to try again later).
SendToSocket
$Request->SendToSocket( $Socket,
NonBlocking => $NonBlocking,
);
SendToSocket() writes the command to the socket.
If the return value was undef
, inspect $MySQL::Replication::Command::Errstr
for an error message.
Parameters
$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 returnundef
if the write would have blocked (indicating to try again later).
Stringify
print $Response->Stringify();
Stringify() returns the stringification of the command. This is what gets written to the socket in SendToSocket().
BUGS
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.
AUTHOR
Alfie John, alfiej at opera.com
LICENSE AND COPYRIGHT
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.