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

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

πŸ’– NAME πŸ’–

okay so bestie, welcome to UR::Service::RPC::Executer (that's the 3pm one, perl gang rise up) β€” it's the base class for modules implementing RPC executers. she's abstract, she's a blueprint, she's iconic πŸ‘‘


🌸 DESCRIPTION 🌸

So this class is an abstract base class used to implement RPC executers. And what is an RPC executer, you ask? It's a module that's meant to have its methods called from another process, and then have the results passed back to the original caller. no cap 🫢

The communication? It happens over a read-write filehandle β€” like a socket β€” by passing UR::Service::RPC::Message objects back and forth. it's giving pen pals but make it IPC πŸ’Œ

Executers are subordinate to a UR::Service::RPC::Server object, and the Server is the one doing the heavy lifting, fr fr:

  • it handles decoding the message passed over the socket
  • it calls the method on the correct executor, in the right context
  • it returns the result back through the file handle

so basically the Server is the main character and the Executer is the extremely competent bestie holding it down behind the scenes πŸ’…


✨ PROPERTIES ✨

  • fh => IO::Handle β€” the file handle that messages are received on and responses are sent to πŸŽ€
  • use_sigio => Boolean β€” if true, the Server will set up a callback on the IO signal to handle execution, so the Server does not need to block in loop(). lowkey a glow-up for your event loop ⭐

πŸ¦‹ METHODS πŸ¦‹

authenticate

  $bool = $exec->authenticate($msg);

This one gets called by execute() right after the message object is deserialized from the filehandle. The default implementation just returns true β€” she's trusting like that πŸ™ˆ

Subclasses can override this to examine the UR::Service::RPC::Message object and return true or false on whether it should allow or disallow execution.

⚠️ If authentication fails, the Executor should modify the Message object in-place with a proper return value and exception. don't skip this part bestie, it matters 😭

execute

  $exec->execute();

Called when the Server detects that data is available to read on its file handle. she then:

  1. deserializes the message
  2. calls authenticate

If authentication fails, she immediately passes the message object back to the caller. bye πŸ‘‹

If authentication succeeds though? then she calls the appropriate method in the Executer package, and creates a brand new Message object with the return value to pass back to the caller. slay ✨

close_connection

  $exec->close_connection();

Called by execute() when it detects that the file handle has closed. rip to that connection, she served her purpose πŸ•ŠοΈ


Derived classes should define additional methods that then become callable by execute(). yes, you're building the menu, the Server just orders from it πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

  • UR::Service::RPC::Server
  • UR::Service::RPC::Message

go read those next, iykyk 🌈


and that's the whole vibe, bestie β€” this page came straight from the User Contributed Perl Documentation, running under perl v5.32.1, dated 2022-01-17. periodt. πŸ’œ

πŸ“¦ where this page comes from