I have a simple Plack app (something like Plack::App::GitHub::WebHook) that I run using plackup
. I perform a lengthy operation in the request handler, which currently makes the app unresponsive to subsequent requests until the operation is finished. How can I perform the operation in background, without blocking other requests? And a follow-up question, how can I keep at most one job running in that background queue?
I’m used to libdispatch, so I’d love something like this:
my $queue = Hypothetical::Concurrency::Queue->new(max_jobs => 1);
$queue->dispatch(sub {
# code
});