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

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

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

okay bestie, so this is a page from the User Contributed Perl Documentation and it's all about a lil class called UR::Service::RPC::Message. pull up a chair, we're gonna get into it 🫢


✨ NAME ✨

UR::Service::RPC::Message β€” a Serializable object that's literally built to be sent around as an RPC message. it's giving "I was made for this". πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, exactly as it goes down:

my $msg = UR::Service::RPC::Message->create(
                         target_class => 'URT::RPC::Thingy',
                         method_name  => 'join',
                         params       => ['-', @join_args],
                         'wantarray'  => 0,
                       );
$msg->send($fh);

my $resp = UR::Service::RPC::Message->recv($fh, 5);

like. iconic. make it, send it, receive it. periodt. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class is used as a message-passing interface by the RPC service modules. that's the whole job. she's the messenger. no cap. 😌


πŸ‘‘ PROPERTIES πŸ‘‘

these ones? the initiating caller should fill 'em in πŸ’–

  • method_name => Text β€” the name of the subroutine the initiator whishes to call. yes girl, whishes, we don't make the rules 🫢
  • target_class => Text β€” the namespace the initiator wants the subroutine to be called in.
  • params => ARRAY β€” the list of parameters to pass to the subroutine.
  • wantarray => Boolean β€” what wantarray() context the subroutine should be called in. lowkey important, don't skip it.

and these ones get assigned after the RPC call to the subroutine 🌈

  • return_values => ARRAY β€” the list of values returned by the subroutine.
  • exception β€” okay so on the receiving side, the subroutine is called within an eval. if there was an exception, exception stores the value of $@, or the empty string. and heads up: the receiving side should also fill-in exception if there was an authentication failure. πŸ”₯
  • fh β€” recv fills this in with the file handle the message was read from.

πŸ’œ METHODS πŸ’œ

send

$bytes = $msg->send($fh);

Serializes the Message object with FreezeThaw and writes the data to the filehandle $fh. Returns the number of bytes written. and ngl, $bytes will be false if there was an error, so check it bestie 😭


recv

$response = UR::Service::RPC::Message->recv($fh,$timeout);

$response = $msg->recv();

Reads a serialized Message from the filehandle and constructs a Message object that is then returned to the caller.

okay but the two forms hit different:

  1. first case: it reads from the given filehandle, waiting a maximum of $timeout seconds with select before giving up. ⏳
  2. second case: it reads from whatever filehandle is stored in $msg to read data from. πŸ¦‹

⭐ SEE ALSO ⭐

UR::Service::RPC::Server, UR::Service::RPC::Executor


and that's the whole page, bestie!! πŸ₯³ this was perl v5.32.1, dated 2022-01-17 β€” shoutout to whoever wrote her, she ate πŸ’…βœ¨ mwah πŸ’–

πŸ“¦ where this page comes from