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

@ -19,6 +19,7 @@ my $build = Module::Build->new(
'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;
}