Gearman::Server(3pm)

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

πŸ’– Gearman::Server πŸ’–

okay bestie, so this is the manual page for Gearman::Server (that's the 3pm perl doc version, iykyk) β€” function call "router" and load balancer. no cap. let's get into it 🫢


✨ NAME ✨

Gearman::Server β€” function call "router" and load balancer. that's the whole vibe. it routes. it balances. it slays πŸ’…


🌸 DESCRIPTION 🌸

so here's the whole situation, fr fr:

you run a Gearman server β€” or, honestly, more likely many of them, because you want both high-availability and load balancing (yes queen, redundancy) β€” and then you have workers. those workers use Gearman::Worker from the Gearman module, or libraries for other languages (perl isn't the only icon here πŸ’…), and they register their ability to do certain functions to all of them.

then you have clients. those use Gearman::Client, Gearman::Client::Async, etc etc, and they request work to be done from one of the Gearman servers. that's it, that's the group chat.

the servers connect them all together, routing function call requests to the appropriate workers, multiplexing responses to duplicate requests as requested, etc. etc. etc. β€” just connecting everybody like the world's most efficient group chat admin 🧚

ok real talk though: more than likely, you want to use the provided gearmand in bin wrapper script, and not use Gearman::Server directly. that's the main character. this is the supporting cast. πŸ’€

πŸŽ€ METHODS πŸŽ€

πŸ’œ new

$server_object = Gearman::Server->new( %options )

creates and returns a new Gearman::Server object β€” and this is the important part bestie, it attaches itself to the Danga::Socket event loop. so the server will begin operating when the Danga::Socket runloop is started. which means... you need to start up the runloop before anything will happen. nothing happens until the runloop goes. that's the rule. periodt.

Options:

  • port β€” specify a port which you would like the Gearman::Server to listen on for TCP connections. not necessary, but useful πŸ‘‘ (ngl it's usually pretty useful)

πŸ¦‹ create_listening_sock

$server_object->create_listening_sock( $portnum, \%options )

add a TCP port listener for incoming Gearman worker and client connections. it's giving "open for business" ✨

Options:

  • accept_per_loop β€” yes, this is an option, and it's literally just sitting there being one
  • local_addr β€” bind socket to only this address

🌈 start_worker

$pid = $server_object->start_worker( $prog )

($pid, $client) = $server_object->start_worker( $prog )

fork and start a worker process named by $prog, and returns the pid β€” or, in scalar/list context depending on which form you use, the pid and client object. two flavors, same icon behavior πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘

  • "gearmand" in bin

and that's the whole page, bestie!! 🌸 go forth and route some function calls, you absolute icon πŸ¦‹

this was perl v5.34.0, dated 2022-06-05, and it's the Gearman::Server(3pm) page from User Contributed Perl Documentation β€” mwah, love that for us πŸ’œβœ¨

πŸ“¦ where this page comes from