NAME
PAGI::App::Delayed - Delayed/deferred response handling
SYNOPSIS
use PAGI::App::Delayed;
# Delay response by fixed time
my $app = PAGI::App::Delayed->new(
app => $inner_app,
delay => 1.5, # seconds
)->to_app;
# Delay until Future resolves
my $app = PAGI::App::Delayed->new(
app => $inner_app,
wait => sub { $some_future },
)->to_app;
DESCRIPTION
Delays response processing by a fixed time or until a Future resolves. Useful for implementing debouncing, polling delays, or waiting for external conditions.
OPTIONS
app- The inner applicationdelay- Fixed delay in seconds before processingwait- Coderef returning a Future to wait fortimeout- Maximum wait time (returns 504 if exceeded)
USE CASES
Rate limiting with delay instead of rejection
Implementing long-polling
Waiting for resource availability
Debouncing rapid requests