NAME

IPC::Manager::Service::Handle - Handle class for connecting to IPC services

DESCRIPTION

This class provides a client-side handle for connecting to IPC services. It manages the connection to a service and provides methods for sending requests and receiving responses.

It composes with IPC::Manager::Role::Service::Select and IPC::Manager::Role::Service::Requests for I/O multiplexing and request/response patterns.

SYNOPSIS

my $handle = IPC::Manager::Service::Handle->new(
    service_name => 'my-service',
    ipcm_info    => $ipcm_info,
);

# Send a synchronous request
my $response = $handle->sync_request({action => 'do_something'});

# Poll for messages
$handle->poll;

# Get buffered messages
my @messages = $handle->messages;

ATTRIBUTES

service_name

The name of the service to connect to (required).

name

The name of this handle connection (optional, defaults to a UUID).

ipcm_info

Connection information for the IPC system (required).

interval

Polling interval in seconds (default: 0.2).

client

The underlying client connection (internal use).

request_callbacks

Hash of request callbacks (internal use).

requests

Hash of pending requests (internal use).

buffer

Array of received messages (internal use).

METHODS

@file_handles = $self->select_handles()

Returns a list of filehandles for select().

$bool = $self->ready()

Returns true if the handle is ready to use

$client = $self->client()

Returns the client connection, creating it if necessary.

$pid = $self->service_pid()

Returns the PID of the peer service.

$res = $self->sync_request($req)

Sends a request and waits for the response. Returns the response.

$res = $self->await_response($id)

Waits for a response to a request. Returns the response when available.

$self->await_all_responses()

Waits for all pending responses to arrive.

@messages = $self->messages()

Returns and clears the message buffer.

$self->poll()
$self->poll($timeout)

Polls for messages. Returns the number of messages received.

If $timeout is provided, waits up to that many seconds for messages.

SOURCE

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

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

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/