diff --git a/Build.PL b/Build.PL index 78b75d2..c669bff 100755 --- a/Build.PL +++ b/Build.PL @@ -9,16 +9,17 @@ my $build = Module::Build->new( dist_author => 'Sergio Iglesias ', dist_abstract => 'Tg bot to generate mtg pdfs.', requires => { - 'Mojolicious' => 0, - 'Path::Tiny' => 0, - 'Moo' => 0, - 'DBI' => 0, - 'DBD::SQLite' => 0, - 'PDF::API2' => 0, - 'PDF::API2::XS' => 0, - 'Image::PNG::Libpng' => 0, - 'YAML::PP' => 0, - 'DateTime' => 0, + 'Mojolicious' => 0, + 'Path::Tiny' => 0, + 'Moo' => 0, + 'DBI' => 0, + 'DBD::SQLite' => 0, + 'PDF::API2' => 0, + 'PDF::API2::XS' => 0, + 'Image::PNG::Libpng' => 0, + 'YAML::PP' => 0, + 'DateTime' => 0, + 'Mojo::UserAgent::Role::Queued' => 0, }, ); $build->create_build_script; diff --git a/lib/TgMagicPdf/PdfBuilder.pm b/lib/TgMagicPdf/PdfBuilder.pm index 66d5d13..c3abcfa 100644 --- a/lib/TgMagicPdf/PdfBuilder.pm +++ b/lib/TgMagicPdf/PdfBuilder.pm @@ -25,7 +25,10 @@ has last_invalid_card => ( has _ua => ( is => 'lazy', ); sub _build__ua { - return Mojo::UserAgent->new; + my $ua = Mojo::UserAgent->new->with_roles('+Queued'); + $ua->max_active(5); + $ua->inactivity_timeout(60); + return $ua; } our $ERR_TOO_MANY_CARDS = 'TOO_MANY_CARDS'; diff --git a/lib/TgMagicPdf/Telegram.pm b/lib/TgMagicPdf/Telegram.pm index 8d96c89..74afffa 100644 --- a/lib/TgMagicPdf/Telegram.pm +++ b/lib/TgMagicPdf/Telegram.pm @@ -156,7 +156,8 @@ sub _pdf_builder { } sub _build__ua ($self) { - my $ua = Mojo::UserAgent->new; + my $ua = Mojo::UserAgent->new->with_roles('+Queued'); + $ua->max_active(5); $ua->inactivity_timeout(60); return $ua; }