RpcRegistry(3I)

✨ RpcRegistry β€” the name space for finding RPC services ✨

okay bestie, welcome to the InterViews Reference Manual entry for RpcRegistry(3I) πŸ’– this one's short and sweet and honestly kinda iconic, so let's get into it 🫢


🌸 NAME 🌸

RpcRegistry β€” a whole name space for finding RPC services πŸ”βœ¨


πŸŽ€ SYNOPSIS πŸŽ€

#include <Dispatch/rpcregistry.h>

that's it. one include. no cap. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, RpcRegistry gives you a name space for finding RPC services, and the whole thing is built on the way NFS filesystems get shared among a group of hosts 🌈 like, that's the vibe it's leaning on, fr fr.

here's how it goes down πŸ‘‡

  • when an RPC service wants to record its host name and port number, it hands over the path of a file, and that's where the info gets stored πŸ“
  • when a client wants to find that RPC service's host name and port number, it hands over the path of a file, and reads the info out of it πŸ“–

and here's the lil detail that matters β€” usually that path is just the name of a file in the current working directory, because different hosts can have different absolute pathnames for the same file living in an NFS filesystem 🀯 so yeah, relative paths are the move.

the way that the RPC service's name space is the name space of the host's filesystem?? and the file's contents give you literally everything you need to open a connection to the RPC service?? obsessed. it's giving "the filesystem is the database" and honestly it ate πŸ”₯


πŸ‘‘ PUBLIC OPERATIONS πŸ‘‘

first things first, every single one of these is a static member function, which means your program can just call it without ever having to instantiate an RpcRegistry object 🧚 no constructor, no drama, no object, just vibes.

and each function returns true if it succeeded, or false if some error occurred ⭐ periodt.

  • boolean record(const char* path, int port) β€” records the RPC service's host name and port number into the given file πŸ’Ύ but bestie, listen: if the file already exists, its previous contents will be lost 😭 so like, be aware. that's the whole warning. it does not care.
  • boolean erase(const char* path) β€” removes the file that stores the RPC service's host name and port number, so that no more clients will be able to contact the RPC service πŸ—‘οΈβœ¨ it's the goodbye button. the door is closed. the service is un-findable.
  • boolean find(const char* path, char*& hostname, int& port) β€” opens the file that stores the RPC service's host name and port number πŸ“‚ if the file does not exist, it returns failure silently (no yelling, no drama, just a quiet false 🀫). if the file does exist, it reads the RPC service's host name and port address out of it πŸŽ‰ and here's the spicy part: if hostname is nil upon entry, then upon exit it will contain the address of a dynamically allocated string β€” which must be freed by the caller 🫢 don't forget, or that's a leak, and leaks are not slay.
lowkey the biggest glow-up here is find failing silently when the file isn't there β€” it's not a bug, it's a feature, it's just minding its own business πŸ’…

🌈 SEE ALSO 🌈

  • RpcService(3I) β€” the other half of this duo, go read it next bestie πŸŽ€

and that's the whole page!! written under the InterViews banner, from the 27 March 1991 era β€” yeah she's vintage, she's retro, she's still serving πŸ’– mwah, go record some services πŸ¦‹βœ¨