further detail OR->connect arguments, and document other bits
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connection.pm
index 349d2a1..f2a90b8 100644 (file)
@@ -15,8 +15,9 @@ use POSIX ":sys_wait_h";
 use Module::Runtime qw(use_module);
 use Scalar::Util qw(weaken blessed refaddr openhandle);
 use JSON::PP qw(encode_json);
-use Moo;
+use Future;
 use Carp qw(croak);
+use Moo;
 
 BEGIN { router()->exclude_forwarding }
 
@@ -58,7 +59,7 @@ has read_channel => (
 );
 
 has on_close => (
-  is => 'rw', default => sub { $_[0]->_install_future_handlers(CPS::Future->new) },
+  is => 'rw', default => sub { $_[0]->_install_future_handlers(Future->new) },
   trigger => sub {
     log_trace { "Installing handlers into future via trigger" };
     $_[0]->_install_future_handlers($_[1])
@@ -233,6 +234,7 @@ BEGIN {
     Object::Remote::Connector::LocalSudo
     Object::Remote::Connector::SSH
     Object::Remote::Connector::UNIX
+    Object::Remote::Connector::INET
   );
 }
 
@@ -324,7 +326,7 @@ sub send_free {
 sub send {
   my ($self, $type, @call) = @_;
 
-  my $future = CPS::Future->new;
+  my $future = Future->new;
   my $remote = $self->remote_objects_by_id->{$call[0]};
 
   unshift @call, $type => $self->_local_object_to_id($future);
@@ -524,7 +526,23 @@ Object::Remote::Connection - An underlying connection for L<Object::Remote>
 
 =head1 DESCRIPTION
 
-This is the class that supports connections to remote objects.
+This is the base class for connections in OR objects. Connections are present
+both in the local and remote parts of each OR pair, and handle the data
+processing for sending OR commands and responses as JSON via the appropiate
+connection mechanism.
+
+=head1 METHODS
+
+=head2 new_from_spec
+
+  my $conn = Object::Remote::Connection->new_from_spec($spec, %args);
+
+Not intended for direct use, called by L<Object::Remote/connect> in a
+L<Future>-compatible way.
+
+Uses the spec to guess the appropiate Object::Remote::Connector::* class to use,
+instantiates it with the spec and any further arguments given, then calls
+C<connect> on it in a L<Future>-compatible way.
 
 =head1 SEE ALSO