Test::Clustericious::Blocking - (Deprecated) Run blocking code in a process using an unholy combination of forks and Mojolicious
version 0.07
use Test::Clustericious::Cluster; use Test::Clustericious::Blocking; use HTTP::Tiny; my $cluster = Test::Clustericious::Cluster->new; $cluster->create('MyApp'); my $url = $cluster->url->clone; $url->path('/someroute'); is blocking { HTTP::Tiny->new->get($url)->{content} }, 'some content'; __DATA__ @@ etc/MyApp.conf --- url: <%= clusters->url %>
NOTE: This module has been deprecated, and may be removed on or after 31 December 2018. Please see https://github.com/clustericious/Clustericious/issues/46.
Warning: This module should be considered experimental.
Clustericious inherits a great asynchronous API from Mojolicious and Test::Clustericious::Cluster is a great way to test one or more Clustericious services in the same process, but if you have a blocking client to test then it gets hard. This module provides a "blocking" function which takes a code block. The code block is executed in a separate process using forks, and the return value is returned. While it is waiting for the thread to complete, it runs the Mojo::IOLoop so that the non-blocking Clustericious service can do its thing.
Although designed to work with Clustericious, it should work it does not depend on any Clustericious code, and should work with any Mojolicious application.
my @values = blocking { ... };
Run the given block in a separate process, allowing it to block without blocking the test overall.
This module uses forks, and turns off EV, in order to work with Mojolicious. Most of those modules were never designed to work together, but hey this is Perl right?
This module should be declared as early as possible in your test file, so that it can turn EV off.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2015 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::Clustericious::Blocking, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Clustericious::Blocking
CPAN shell
perl -MCPAN -e shell install Test::Clustericious::Blocking
For more information on module installation, please visit the detailed CPAN module installation guide.