Documentation
¶
Overview ¶
Package socket gives a daemon its Unix socket and a client its connection to it. The file mode is the access control and the user account the trust boundary: the socket's directory is 0700, the socket 0600, both owned by the user, and there are no tokens or TLS.
path := socket.Path(paths.For(id.Name).Runtime, id.Name)
ln, err := socket.Listen(ctx, path) // the daemon; serve it with httpserver's Serve
client := &http.Client{Transport: &http.Transport{
DialContext: socket.Dialer(path, "myapp service start"),
}}
resp, err := client.Get("http://myapp/v1/drafts") // the host is not used
Listen refuses when another daemon holds or answers on the socket, and removes a socket file only when nobody answers. The dial refuses a socket or directory another user owns. Every refusal is a failure with a next step.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dialer ¶
Dialer returns an http.Transport DialContext that connects to the socket at path whatever the request's host. It refuses a socket or directory another user owns (permission), a symlink or other file in place of the socket (conflict), and fails as remote with start as the next step when no daemon answers.
Types ¶
This section is empty.