+++ /dev/null
-package Tak::Remote;
-
-use Moo;
-
-has router => (is => 'ro', required => 1);
-
-has name => (is => 'ro', required => 1);
-
-sub blocking_request {
- my ($self, @payload) = @_;
- my ($done, @result);
- my $cb = sub { my ($self, $tag, @r) = @_; @result = @r; $done = 1; };
- $self->router->send_request($self, $cb, $self->name, @payload);
- $self->router->run_until($done);
- return @result;
-}
-
-1;
+++ /dev/null
-package Tak::World;
-
-use Tak::JSONChannel;
-use Tak::ServiceManager;
-use Tak::ModuleLoader;
-use Tak::Router;
-use Tak::Remote;
-
-use Moo;
-
-has channel_args => (is => 'ro', required => 1);
-
-sub new_from_stdio {
- open my $stdin, '<&', \*STDIN;
- open my $stdout, '>&', \*STDOUT;
- shift->new(channel_args => { read_fh => $stdin, write_fh => $stdout });
-}
-
-has router => (is => 'lazy');
-
-sub _build_router {
- my ($self) = @_;
- my $channel = Tak::JSONChannel->new($self->channel_args);
-
- my $router = Tak::Router->new(
- channel => $channel
- );
-
- my $remote = Tak::Remote->new(
- router => $router,
- name => 'module_sender'
- );
-
- my $loader = Tak::ModuleLoader->new(
- remote => $remote
- );
-
- push @INC, $loader->inc_callback;
-
- return $router;
-}
-
-sub run { shift->router->run }
-
-1;
+++ /dev/null
-package Tak::WorldHandle;
-
-use IPC::Open2 ();
-use Tak::Router;
-use Tak::JSONChannel;
-use Tak::ModuleSender;
-use Tak::Remote;
-use IO::All;
-use Moo;
-
-sub Tak::WorldHandle::_local::open2 {
- shift;
- my $pid = IPC::Open2::open2(my $out, my $in, @_)
- or die "Couldn't open2 child: $!";
- return ($in, $out, $pid);
-}
-
-has connection => (is => 'ro', required => 1);
-
-sub new_local {
- shift->new(connection => bless({}, 'Tak::WorldHandle::_local'))
-}
-
-sub new_remote {
- my ($class, $target) = @_;
- $class->new(connection => do {
- require Net::OpenSSH;
- Net::OpenSSH->new($target);
- });
-}
-
-has router => (is => 'lazy');
-
-sub _build_router {
- my ($self) = @_;
-
- my ($stdin, $stdout) = $self->connection->open2('perl -');
-
- $stdin->print(io('maint/mk-fat |')->all, "__END__\n");
-
- my $channel = Tak::JSONChannel->new(
- read_fh => $stdout, write_fh => $stdin
- );
-
- my $router = Tak::Router->new(
- channel => $channel
- );
-
- $router->register(module_sender => Tak::ModuleSender->new);
-
- return $router;
-}
-
-sub remote_for {
- my ($self, $name) = @_;
- Tak::Remote->new(router => $self->router, name => $name);
-}
-
-1;