评论:
jh125486:
Loves_Portishead:How arbitrary? gRPC seems to do well. And if that isn’t supported there’s good old fashioned JSON.
BadlyCamouflagedKiwi:+1 for GRPC
lhxtx:What's the relationship between the two programs? If one spawns another then communication over stdin / stdout can work well - although you also need a serialisation format, JSON is likely easy and protobufs are nice for more structure.
(Am also +1 for gRPC but you're after something lighter so...)
holyjeff:gRPC is fantastic.
SeerUD:grpc or json are both possible though I think they are both a bit too much. Is there a lightweight way you can recommend ?
dfndoe:In what way do you mean a bit much?
gRPC is actually really easy to use, but if you want to get simpler (though more difficult) then you could always just use a raw TCP connection and pass bytes around yourself - but why go through all of that hassle if you don't need to? gRPC will also be more lightweight than making some JSON web service too since Protobuf is a faster (to encode and decode) and more lightweight data format.
meta_leap:If go is spawning the other language then json on stdin/stdout is pretty straightforward and makes for a very language agnostic interface.
If go is spawning the other language then json on stdin/stdout is pretty straightforward
Even when it's the other way around, too! I'm quite keen on line-based IPC if the processes are all under your own development/control and are all "reasonably fast" with regards to eg. JSON. I struggle to find a better protocol for line-based text-based IPC ---custom stuff always seems to end up growing to the point where switching to JSON is the sane choice--- and I like line-based-text-based because one can pose as the-other-process interactively via the terminal when it becomes necessary for a bit. Also it's handy to have the 2 output channels built-in to every process, for example "stdout for IPC, stderr for debug-logging to the other side".
Performance-wise seems fine if the processes are "ping-ponging structured messages" between each other, rather than say continuously-streaming (where raw-bytes serializing might prove more efficient).
