Documentation ¶
Overview ¶
Package domainsockets implements an OS level procedure calling service based on the Unix Domain Sockets IPC.
This implementation is simplistic in that it does not try to duplicate more complex communication mechansims, such as message splitting (into packets), assembly of disjointed messages, etc...
Instead a client sends an entire message across the socket and receives a response. Calls are syncronous. The client can send multiple messages simultaneously (calls are thread safe).
At this point, local security is a concern, as there is not authorization control against users on the same OS. This may be a concern depending on if the OS is shared between untrusted users or if the tmp directory is exposed to other containers instead of being container local only.
Finally, compatibility is only currently guarenteed between client and servers using the same version of code. Some of the underlying mechansims may be changed in the future. Once this is completely settled, this warning will go away.
Package domainsockets prvoides for a unix domain socket server, similar to an RPC server like Grpc except that it is intended to only connect unix processes on the same device.
Usage ¶
Usage is fairly simple:
s, err := NewServer() if err != nil { // Do something } s.Register(header, handler) if err := s.Start(); err != nil { // Do something }
Index ¶
Constants ¶
const ( // ClientKeepAlive indicates that the client is still alive. ClientKeepAlive = 0 // ClientData indicates that the client is making a request to the server. ClientData = 1 )
const ( // ServerError indicates there was an error and that Data will be a string // message of why. ServerError = 0 // ServerData indicates that the server is returning data. ServerData = 1 )
const (
MiB = 1048576
)
MiB is a Mebibyte (sometimes called a Megabyte).
Variables ¶
var ( KeepAlive = byte(011) LenTotal = 36 )
Functions ¶
func SetupDecode ¶
SetupDecode decodes a setup message into a UUIDv4 identifer. This ID is the unix socket in os.TempDir that the remote side is listening on.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a client to a Domain Socket server.
func DialServer ¶
DialServer dials a Unix Domain Socket where a server is listening and returns a client to the server.
type ClientMsg ¶
ClientMsg represents the data to be sent on the wire from the client to the server.
type Handler ¶
Handler provides a function that answers a request from a client and returns a response. The ServerMsg returned must have the same ID as req.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides a Unix Domain Socket procedure calling service.
func (*Server) Close ¶
func (s *Server) Close()
Close closes all connections. This server object cannot be reused.
Directories ¶
Path | Synopsis |
---|---|
Package domainsockets prvoides for a unix domain socket server, similar to an RPC server like Grpc except that it is intended to only connect unix processes on the same device.
|
Package domainsockets prvoides for a unix domain socket server, similar to an RPC server like Grpc except that it is intended to only connect unix processes on the same device. |