further detail OR->connect arguments, and document other bits
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / UNIX.pm
CommitLineData
0e547800 1package Object::Remote::Connector::UNIX;
2
3use IO::Socket::UNIX;
4use Moo;
5
6with 'Object::Remote::Role::Connector';
7
fbd3b8ec 8has socket_path => (is => 'ro', required => 1);
9
0e547800 10sub _open2_for {
fbd3b8ec 11 my ($self) = @_;
12 my $path = $self->socket_path;
0e547800 13 my $sock = IO::Socket::UNIX->new($path)
14 or die "Couldn't open socket ${path}: $!";
15 ($sock, $sock, undef);
16}
17
18no warnings 'once';
19
55c0d020 20push @Object::Remote::Connection::Guess, sub {
0e547800 21 for ($_[0]) {
22 if (defined and !ref and /^(?:\.\/|\/)/) {
c824fdf3 23 my $socket = shift(@_);
24 return __PACKAGE__->new(@_, socket_path => $socket);
0e547800 25 }
26 }
27 return;
28};
29
301;
4e25b1fd 31
32=head1 NAME
33
34Object::Remote::Connector::UNIX - A connector for UNIX sockets
35
8dbf62a5 36=head1 DESCRIPTION
37
38Used to create a connector that talks to a unix socket. Invoked by
39L<Object::Remote/connect> if the connection spec looks like a unix path name
40that's either absolute, or relative to C<.>.
41
4e25b1fd 42=head1 ARGUMENTS
43
44Inherits arguments from L<Object::Remote::Role::Connector> and provides the
45following:
46
47=head2 socket_path
48
8dbf62a5 49When invoked via L<Object::Remote/connect>, specified via the connection spec,
50and not overridable.
51
52The path name of the unix socket to connect to. Passed to L<IO::Socket::UNIX>.
53
4e25b1fd 54=cut