NAME

PGObject::Util::Replication::Master - Manage Database Masters

VERSION

Version 0.01

SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

 use PGObject::Util::Replication::Master;

 my $masterdb = PGObject::Util::Replication::Master->new(
                  host => 'localhost',
                  port => 5432,
);

# also slot management
$master->slots();
$master->addslot('slotname');
$master->removeslot('slotname');

SERVER PROPERTIES

host

Hostname or IP address

port

defaults to 5432

user

Username for the connection string. If not provided, dbi defaults to the username for the system user of the script running this module

password

Password for connecting, if needed based on pg_hba.conf settings

dbname

Database name for connecting. Defaults to postgres

autocommit

Whether to autocommit statements. This defaults to true.

persist_connect

If set, save the connection for repeated use. Defaults to off which means we reconnect for each operation.

Set to true if you are doing a lot of operations.

manage_vars

This is the variables we read or write. It is intended to be unmodified as it is.

METHDOS

connect

Returns a DBI connection to the database and checks to make sure we are not in recovery. If we are in recovery, an exception is thrown.

disconnect

Disconnect, if using persist_connect

can_manage

Returns true if the user credentials allow us to create and manage replication slots.

This requires either superuser or replication attributes for the user.

slots([prefix])

Lists all replication slots, their lags, etc.

getslot($name)

Returns info from a single named slot

addslot

Adds a named replication slot

deleteslot($name)

Deletes a named replication slot

ping_wal()

connects to the db and asks for the current wal log series number (lsn) and related information. Is intended to be used for monitoring and to deliver telemtry data.

Returned hashref includes:

snapshot_lsn

The curret query log sequence number at the time of snapshot epoch

snapshpt_epoch

The current epoch at time of snapshot (technically small variance is possible here).

delta_bytes

Number of bytes sent to the WAL since last time this was called (if known). Will be undef on first run after loading module.

delta_secs

Number of seconds (including fractional seconds) since last run if known. Will be undef on first run after loading module.

bytes_per_sec

Number of bytes per sec on average since last run. Will be undef on first run.

On the first run, we will get the lsn and the epoch of the current snapshot but no deltas because we lack a comparison. On subsequent runs we get telemetry.

readconfig

Reads all settings from the pg instance.

addconfig

Adds one more config setting to the managed list and sets it to the default

setconfig

Sets a config value for later config file writing.

configcontents

Returns a file of the structure of the config file, based on all managed values.

AUTHOR

Chris Travers, <chris.travers at adjust.com>

BUGS

Please report any bugs or feature requests to bug-pgobject-util-replication-master at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Util-Replication-Master. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc PGObject::Util::Replication::Master

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2017 Chris Travers.

This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause

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 Adjust.com 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 OWNER 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.