Async-Microservice
view release on metacpan or search on metacpan
lib/Async/MicroserviceReq.pm view on Meta::CPAN
use namespace::autoclean;
use URI;
use AnyEvent::IO qw(aio_load);
use Try::Tiny;
use JSON::XS;
use Plack::MIME;
use MooseX::Types::Path::Class;
use Future::AsyncAwait;
use Log::Any qw($log);
use HTTP::Negotiate qw(choose);
use Scalar::Util qw(weaken);
our $json = JSON::XS->new->utf8->pretty->canonical;
our @no_cache_headers =
( 'Cache-Control' => 'private, max-age=0', 'Expires' => '-1' );
our $pending_req = 0;
has 'method' => ( is => 'ro', isa => 'Str', required => 1 );
has 'headers' => ( is => 'ro', isa => 'Object', required => 1 );
has 'path' => ( is => 'ro', isa => 'Str', required => 1 );
has 'content' => ( is => 'ro', isa => 'Str', required => 1 );
lib/Async/MicroserviceReq.pm view on Meta::CPAN
else {
$redirect_host_port = $redirect_host . ':' . $redirect_port;
}
return URI->new( $url_scheme . '://' . $redirect_host_port . '/' );
}
sub _build_warn_running_too_long {
my ($o_self) = @_;
weaken( my $self = $o_self );
return AnyEvent->timer(
'after' => $self->request_timeout,
'interval' => $self->request_timeout,
'cb' => sub {
$log->errorf(
'request %s %s running too long for %d seconds',
$self->method, $self->path, ( time - $self->request_start ),
);
},
);
( run in 2.585 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )