what you refer to is more generally known as a remote procedure call.
https://en.wikipedia.org/wiki/Remote_procedure_call
if you google for "rpc node" you will find some libraries that people have built, but the one I recommend is gRPC because it's backed by google and has good cross language support. Others might recommend apache thrift but I haven't used it. the other suggestion of expose an API endpoint is also a valid way to do this, but the code at the end does not look as clean.
RE: Musing Posts