HTTP::...:Engine(3pm)

πŸ“¦
version 0.304 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– HTTP::...:Engine(3pm) β€” the whole vibe πŸ’–

okay so bestie, you found the manual page for HTTP::Proxy::Engine (that's the HTTP::...:Engine(3pm) situation, from the User Contributed Perl Documentation, mwah) ✨ and ngl, it's a good one. it's the generic child process manager engine for HTTP::Proxy. yes, the name has dots in it. we don't ask questions. we accept it. 🫢


🌸 NAME 🌸

HTTP::Proxy::Engine β€” the generic child process manager engine for HTTP::Proxy. that's it, that's the girl. πŸ’…


✨ SYNOPSIS ✨

here's how you actually use her, no cap:

use HTTP::Proxy;

# use the default engine for your system
my $proxy = HTTP::Proxy->new();

# choose one
my $proxy = HTTP::Proxy->new( engine => 'Old' );

literally just use HTTP::Proxy; and you're in. let it pick the default engine for your system (she knows what she's doing), or be a control freak about it and pass engine => 'Old'. both are valid. main character behavior. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so HTTP::Proxy::Engine is a front-end to the actual proxy engine classes. think of her as the friend who handles the intros β€” she doesn't do the whole thing herself, she sets you up with the engine that does. πŸ’

and what does an engine do? the role of an engine is to implement the main fork+serve loop, with all the required bookkeeping. that's the whole job. it's giving "I do the admin so you can vibe." and honestly? it's also a great way to test various implementations and/or try out new algorithms without too much difficulty. lowkey genius. 🌈


πŸ’… METHODS πŸ’…

new()

creates a brand new engine, fresh out the box. πŸŽ€

  • the engine parameter is what decides which kind of engine gets created
  • every other parameter gets passed along to the underlying engine

also, this method implements the subclass constructor too β€” subclasses obviously don't need the engine parameter, since they already know who they are. self-aware queens only. πŸ’œ


🧚 CREATING YOUR OWN ENGINE 🧚

you can absolutely make your own engine, bestie!! it's a whole thing and it's fun. just create a simple subclass of HTTP::Proxy::Engine with the following methods:

start()

this method should handle any initialisation required when the engine starts. that's her moment. the opening number. ✨

run()

this method is the main loop of the master process. it defines how child processes are forked, checked, and killed. so, like, everything. 😀

the engine MUST have a run() method, and it will be called again and again until the proxy exits. no run(), no engine. periodt.

$self->proxy->daemon returns the listening socket that can accept() connections. the child must call $self->proxy->serve_connections() on the returned socket to handle the actual TCP connections. don't skip that part, fr fr, that's the whole point. πŸ”₯

stop()

this optional method should handle any cleanup procedures when the engine stops β€” typically when the main proxy process is killed. optional, but polite. 🫢

a subclass may also define a %defaults hash (with our) that contains the default values for the fields used internally. (yes the original says "internaly". we leave it, we don't touch, it's iconic. πŸ’€)


πŸŽ€ METHODS PROVIDED TO SUBCLASSES πŸŽ€

HTTP::Proxy::Engine hands these methods to its subclasses like little gifts:

proxy()

returns the HTTP::Proxy object that runs the engine. your proxy, your girl. 🌸

max_clients()

get or set the maximum number of TCP clients β€” that is to say, the maximum number of forked child processes. πŸ‘―

some engines may understand a value of 0 as do not fork at all. this is what HTTP::Proxy::Engine::Legacy does. so heads up before you go passing 0 around like it's nothing. 🚨

make_accessors( @names )

creates accessors named after @names in the subclass package. all accessors are read/write. it's a utility method β€” a lil helper, a lil bestie. ✨

this is a class method. πŸ“Œ


πŸ‘‘ AUTHOR πŸ‘‘

Philippe "BooK" Bruhat, <book@cpan.org>. legend behavior honestly. πŸ’–


Copyright 2005-2015, Philippe Bruhat. πŸ“


🌈 LICENSE 🌈

this module is free software; you can redistribute it or modify it under the same terms as Perl itself. slay, open source icon. πŸ¦‹


and that's the whole page, bestie!! no notes, we ate. πŸ’…βœ¨

this was perl v5.36.0, dated 2022-12-04, and yes, the page you just read is HTTP::...:Engine(3pm) β€” mwah, drink some water, go fork a process responsibly. πŸ“πŸ§šπŸ’–

πŸ“¦ where this page comes from