forked from Elara6331/itd
Add doc comments
This commit is contained in:
parent
a787e58128
commit
33f772d80c
@ -10,11 +10,15 @@ import (
|
|||||||
|
|
||||||
const DefaultAddr = "/tmp/itd/socket"
|
const DefaultAddr = "/tmp/itd/socket"
|
||||||
|
|
||||||
|
// Client is a client for ITD's socket API
|
||||||
type Client struct {
|
type Client struct {
|
||||||
conn drpc.Conn
|
conn drpc.Conn
|
||||||
client rpc.DRPCITDClient
|
client rpc.DRPCITDClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New connects to the UNIX socket at the given
|
||||||
|
// path, and returns a client that communicates
|
||||||
|
// with that socket.
|
||||||
func New(sockPath string) (*Client, error) {
|
func New(sockPath string) (*Client, error) {
|
||||||
conn, err := net.Dial("unix", sockPath)
|
conn, err := net.Dial("unix", sockPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,6 +36,8 @@ func New(sockPath string) (*Client, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewFromConn returns a client that communicates
|
||||||
|
// over the given connection.
|
||||||
func NewFromConn(conn io.ReadWriteCloser) (*Client, error) {
|
func NewFromConn(conn io.ReadWriteCloser) (*Client, error) {
|
||||||
mconn, err := newMuxConn(conn)
|
mconn, err := newMuxConn(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -44,10 +50,12 @@ func NewFromConn(conn io.ReadWriteCloser) (*Client, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FS returns the filesystem API client
|
||||||
func (c *Client) FS() *FSClient {
|
func (c *Client) FS() *FSClient {
|
||||||
return &FSClient{rpc.NewDRPCFSClient(c.conn)}
|
return &FSClient{rpc.NewDRPCFSClient(c.conn)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the client connection
|
||||||
func (c *Client) Close() error {
|
func (c *Client) Close() error {
|
||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
|
|
||||||
var _ drpc.Conn = &muxConn{}
|
var _ drpc.Conn = &muxConn{}
|
||||||
|
|
||||||
|
// muxConn implements drpc.Conn using the yamux
|
||||||
|
// multiplexer to allow concurrent RPCs
|
||||||
type muxConn struct {
|
type muxConn struct {
|
||||||
conn io.ReadWriteCloser
|
conn io.ReadWriteCloser
|
||||||
sess *yamux.Session
|
sess *yamux.Session
|
||||||
|
Loading…
Reference in New Issue
Block a user