Answer the question
In order to leave comments, you need to log in
How to write CLI client for golang daemon?
Hello everyone
There is a go daemon that provides an http api. I do not know how to make an architecture and write a CLI client?
The initialization of the daemon itself takes some time (several seconds) and loads the processor. The task was to write a CLI client that would:
Answer the question
In order to leave comments, you need to log in
Let the CLI client connect only to the running server over the network via localhost.
And it uses either the same http api, or another, specifically for CLI control.
How do clis work for (let's say) Open vSwitch or other non-networking daemons (examples don't come to mind)?
I have already thought about implementing storage in a local database: sqlite / xml files. But how are functions called through cli not over the network?
RemoteProcedureCall golang.org/pkg/net/rpc to register the required methods on the daemon as exportable. Call via unix sockets (you can even use stdin). General data is simply stored in a file, if you need RAM speed, then MemoryMappedFile golang.org/pkg/syscall/#Mmap
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question