package HomePanel::AsyncUA; use Moo; use namespace::autoclean; use Net::Async::HTTP; has loop => ( is => 'ro', required => 1, ); has agent => ( is => 'lazy', ); sub _build_agent { my ($self) = @_; my $agent = Net::Async::HTTP->new( max_connections_per_host => 1, stall_timeout => 10, ); $self->loop->add($agent); return $agent; } sub get { my ($self,$uri) = @_; return $self->agent->GET($uri)->get } 1;