NAME

IPC::Manager - Decentralized local IPC through various protocols.

DESCRIPTION

IPC::Manager provides a way to do message based IPC between local (on a single machine) processes. It provides multiple protocols for doing this, as well as pluggable serialization.

The idea is to first initialize a data store, provide the info to access the data store, then any process may use that info to send/recieve messages. The datastore can be temporary (guarded) or persistent.

SYNOPSIS

use IPC::Manager qw/ipcm_connect ipcm_spawn/;

# Let the system pick a protocol and serialization
my $ipcm = ipcm_spawn();

my $info = $ipcm->info;
print "You can connect to the IPC using this string: $info\n";

# Get a connection
my $con1 = ipcm_connect(con1 => $info);
my $con2 = ipcm_connect(con2 => $info);

# Send a message
$con1->send_message(con2 => {hello => 'world'});

# Get messages
if (my @messages = $con2->get_messages) {
    # hashref: {hello => 'world'}
    my $payload = $message[0]->content;
    ...
}

# Cleanup the datastore (unless `guard => 0` was passed in).
$guard = undef;

The idea is to use the ipcm data store as the medium for transferring messages. You can use the string returned by $ipcm->info from any process to reach the data store.

You can set up persistent data stores, in which case the ipcm_spawn() export is not needed. How to set up a persistent data store is documented in each client protocol.

Messages are instances of IPC::Manager::Message. You can make the instances yourself manually and send them, or you can let send_message() create them for you:

$con1->send_message(con2 => IPC::Manager::Message->new(content => \%CONTENT, ...));
$con1->send_message(con2 => \%CONTENT);

EXPORTS

CLIENT PROTOCOLS

See IPC::Manager::Client for common methods across all client types.

FileSystem Based

These are all based off of IPC::Manager::Base::FS. These are all based on a directory structure of some kind.

DBI Based

These are all based off of IPC::Manager::Base::DBI. These all use a database as the message store.

These all have 1 table for tracking clients, and another for tracking messages. Messages are deleted once read. The 'route' is a DSN. You also usually need to provide a username and password.

my $con = ipcm_connect(my_con => $info, user => $USER, pass => $PASS);

CLEANUP

When using a temporary instance that cleans up after itself, the cleanup process will send terminations messages to all clients, then wait for them to disconnect. It will also tell you if there is a mismtach between sent and recieved messages.

See IPC::Manager::Spawn for more information.

SOURCE

The source code repository for IPC::Manager can be found at https://https://github.com/exodist/IPC-Manager.

MAINTAINERS

AUTHORS

COPYRIGHT

Copyright Chad Granum exodist7@gmail.com.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/