NAME
PAGI::Utils - Shared utility helpers for PAGI
SYNOPSIS
use PAGI::Utils qw(handle_lifespan);
return await handle_lifespan($scope, $receive, $send,
startup => async sub { my ($state) = @_; ... },
shutdown => async sub { my ($state) = @_; ... },
) if $scope->{type} eq 'lifespan';
FUNCTIONS
handle_lifespan
return await handle_lifespan($scope, $receive, $send,
startup => async sub { my ($state) = @_; ... },
shutdown => async sub { my ($state) = @_; ... },
) if $scope->{type} eq 'lifespan';
Consumes lifespan events, runs registered startup/shutdown hooks, and sends the appropriate completion messages. Hooks are taken from $scope->{'pagi.lifespan.handlers'}, and optional startup and shutdown callbacks can be passed in via %opts.
Important: This function will croak if called with a non-lifespan scope. Always check $scope->{type} eq 'lifespan' before calling, as shown in the synopsis.