AnyEvent::FCGI(3pm)

πŸ“¦
version 0.04 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ AnyEvent::FCGI πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section of your friendly neighbourhood manual, and it's all about AnyEvent::FCGI β€” a non-blocking FastCGI server. yes. that's the whole vibe. non-blocking. FastCGI. server. slay. 🫢


🌸 NAME 🌸

AnyEvent::FCGI β€” non-blocking FastCGI server. that's it, that's the name, and honestly? iconic. πŸ‘‘


✨ SYNOPSIS ✨

here's the moment you've been waiting for, the little taste test, the vibe check in code form:

use AnyEvent;
use AnyEvent::FCGI;

my $fcgi = new AnyEvent::FCGI(
    port => 9000,
    on_request => sub {
        my $request = shift;
        $request->respond(
            'OH HAI! QUERY_STRING is ' . $request->param('QUERY_STRING'),
            'Content-Type' => 'text/plain',
        );
    }
);

my $timer = AnyEvent->timer(
    after => 10,
    interval => 0,
    cb => sub {
        # shut down server after 10 seconds
        $fcgi = undef;
    }
);

AnyEvent->loop;

not me getting emotional over a # shut down server after 10 seconds comment 😭 she really said "know your limits, queen".


πŸ’œ DESCRIPTION πŸ’œ

so basically: this module implements a non-blocking FastCGI server for event based applications. that's the whole plot. no cap. πŸ”₯


πŸŽ€ METHODS πŸŽ€

new

this function creates a new FastCGI server and hands you back a fresh, brand-new instance of a AnyEvent::FCGI object. πŸ¦‹

and bestie, listen β€” to shut down the server you just remove all references to this object. that's the whole shutdown ritual. let it go, let it float into the void, garbage collector does the rest. periodt. πŸ’…

🌈 PARAMETERS 🌈

  • port => $port β€” the TCP port the FastCGI server will listen on. pick a good one, she's staying a while. πŸ“
  • host => $host β€” the TCP address the FastCGI server will listen on. if it's undefined, 0.0.0.0 gets used instead. no host? no problem, 0.0.0.0 is the default bestie. ✨
  • socket => $path β€” path to a UNIX domain socket to listen on. and heads up: if you specify this, the host and port parameters get ignored. completely. ghosted. πŸ’€ she said "unix socket is my main character now".
  • on_request => sub { } β€” a reference to a handler that gets called when a new FastCGI request shows up. she will be invoked as:
$on_request->($request)

where $request is gonna be a brand spanking new AnyEvent::FCGI::Request object. πŸ’–

  • backlog => $backlog β€” optional, bestie. an integer number of socket backlog (that's the listen queue for you and me). optional. did she stutter? no. 🌸

πŸ‘€ SEE ALSO πŸ‘€

  • AnyEvent
  • AnyEvent::FCGI::Request

and lowkey important lore: this module is based on FCGI::Async and FCGI::EV. respect the ancestors. 🫑


🧚 LICENSE 🧚

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. go read perlartistic if you want the full tea. πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

Vitaly Kramskikh, <vkramskih@cpan.org> β€” absolute legend, gave us this whole module, we love her for it. πŸ’


ok that's the whole page bestie, go forth and build your non-blocking FastCGI server, you're gonna ate that πŸ’…βœ¨

this masterpiece dropped as perl v5.36.0 on 2022-10-14, and it lives in AnyEvent::FCGI(3pm) β€” stay slaying, stay non-blocking, mwah πŸ’–πŸŒˆ

πŸ“¦ where this page comes from