Adding a limit of requests.

This commit is contained in:
Sergiotarxz 2024-05-23 16:43:47 +02:00
parent 1117f6d52f
commit 8d685edec1
3 changed files with 17 additions and 12 deletions

View File

@ -9,16 +9,17 @@ my $build = Module::Build->new(
dist_author => 'Sergio Iglesias <contact@owlcode.tech>',
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;

View File

@ -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';

View File

@ -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;
}