UR::Se...Server(3pm)

πŸ“¦
version 0.470 Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– UR::Se...Server(3pm) β€” aka UR::Service::RPC::Server πŸ’–

okay bestie, so you know those Perl docs where the title gets all chopped up because the terminal is being dramatic? yeah. this is UR::Service::RPC::Server, straight out of the User Contributed Perl Documentation, manual section 3pm. she's a whole class for building RPC servers and she is so ready to be your main character. πŸŽ€


✨ NAME ✨

UR::Service::RPC::Server β€” a class for implementing RPC servers. that's the whole pitch. class. servers. RPC. periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe in code form, no cap:

  my $executer = Some::Exec::Class->create(fh => $fh);

  my $server = UR::Service::RPC::Server->create();
  $server->add_executer($executer);

  $server->loop(5);  # Process messages for 5 seconds

so you spin up an executer from Some::Exec::Class with a filehandle, make yourself a server, add_executer that executer to it, and then loop for 5 seconds like the icon you are. 🌈


🌸 DESCRIPTION 🌸

ngl, the RPC server implementation isn't fleshed out very well yet, and it may change in the future. that's the official word, bestie, i'm not making it up. so like… ship it, but keep an eye on her. she's still growing. πŸ¦‹


πŸ‘‘ METHODS πŸ‘‘

add_executer

$server->add_executer($exec);

okay so this is where you incorporate a new UR::Service::RPC::Executer instance into this server. it literally takes that Executer's filehandle and drops it into its own internal IO::Select object. that's it. that's the move. your executer is now part of the family. 🫢

loop

$server->loop();

$server->loop(0);

$server->loop($timeout);

enter the Server's event loop for the given number of seconds. cute, right? but here's the fine print, and you need to know this:

  • if the timeout is undef, it will stay in the loop forever. forever forever. like, she's not coming back on her own. ⭐
  • if the timeout is 0, it makes a single pass through the readable filehandles and calls execute on their Executer objects. one pass. in and out. blink and you'll miss her. πŸ’€
  • if the return value of an Executer's execute method is false, that Executer's file handle gets removed from the internal Select object. so like, return false and you're out of the group chat. not me being dramatic, that's literally what it does. 😭
heads up bestie: undef means she loops forever. plan accordingly. ✨

πŸ’œ SEE ALSO πŸ’œ

go read these next, i promise they're worth it:

  • UR::Service::RPC::Executer
  • UR::Service::RPC::Message

and that's the whole page, babe. this gem was documented in perl v5.32.1 and last touched on 2022-01-17 β€” so it's giving vintage-but-still-slay. go build something iconic with it. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from