NAME

IPC::MicroSocket::Client - client connector

SYNOPSIS

use v5.36;
use Future::AsyncAwait;
use IPC::MicroSocket::Client;

my $client = IPC::MicroSocket::Client->new_unix( path => "my-app.sock" );

say await $client->request( "PING" );

DESCRIPTION

This module provides the client connector class for IPC::MicroSocket.

CONSTRUCTOR

new_unix

$client = IPC::MicroSocket::Client->new_unix( path => $path );

A convenience constructor for connecting a new client instance to a given UNIX socket path.

new_inprocess

$client = IPC::MicroSocket::Client->new_inprocess( $server );

Since version 0.04.

Creates a new client instance connected to an existing IPC::MicroSocket::Server instance within the same process. This allows operation of code that would normally use a separately-connected client to run from within the same process as the server.

Currently the implementation uses a PF_UNIX socketpair to transport bytes as if an external socket was connected, but a later version of this module may make use of some other, more efficient internal mechanism instead.

METHODS

request

@response = await $client->request( @args );

Sends a REQUEST frame with the given arguments, waiting for a response. The returned future will complete with its RESPONSE frame.

subscribe

await $client->subscribe( $topic, $on_recv );

$on_recv->( @args );

Sends a SUBSCRIBE frame for the given topic name, then waits indefinitely for PUBLISH frames that match it. Each received frame will invoke the $on_recv callback.

Note that the Future returned by this method should not complete in normal circumstances but will remain pending forever.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>