unix socket connector
Matt S Trout [Mon, 11 Jun 2012 23:23:04 +0000 (00:23 +0100)]
lib/Object/Remote/Connector/UNIX.pm [new file with mode: 0644]

diff --git a/lib/Object/Remote/Connector/UNIX.pm b/lib/Object/Remote/Connector/UNIX.pm
new file mode 100644 (file)
index 0000000..614609a
--- /dev/null
@@ -0,0 +1,26 @@
+package Object::Remote::Connector::UNIX;
+
+use IO::Socket::UNIX;
+use Moo;
+
+with 'Object::Remote::Role::Connector';
+
+sub _open2_for {
+  my ($self,$path) = @_;
+  my $sock = IO::Socket::UNIX->new($path)
+    or die "Couldn't open socket ${path}: $!";
+  ($sock, $sock, undef);
+}
+
+no warnings 'once';
+
+push @Object::Remote::Connection::Guess, sub { 
+  for ($_[0]) {
+    if (defined and !ref and /^(?:\.\/|\/)/) {
+      return __PACKAGE__->new->connect($_[0]);
+    }
+  }
+  return;
+};
+
+1;