From 33f772d80cd2532b4216359178fde96ba9d28897 Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Tue, 3 Jan 2023 09:30:04 -0800 Subject: [PATCH] Add doc comments --- api/api.go | 8 ++++++++ api/drpc.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/api/api.go b/api/api.go index 59d6c73..aeb9656 100644 --- a/api/api.go +++ b/api/api.go @@ -10,11 +10,15 @@ import ( const DefaultAddr = "/tmp/itd/socket" +// Client is a client for ITD's socket API type Client struct { conn drpc.Conn 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) { conn, err := net.Dial("unix", sockPath) if err != nil { @@ -32,6 +36,8 @@ func New(sockPath string) (*Client, error) { }, nil } +// NewFromConn returns a client that communicates +// over the given connection. func NewFromConn(conn io.ReadWriteCloser) (*Client, error) { mconn, err := newMuxConn(conn) if err != nil { @@ -44,10 +50,12 @@ func NewFromConn(conn io.ReadWriteCloser) (*Client, error) { }, nil } +// FS returns the filesystem API client func (c *Client) FS() *FSClient { return &FSClient{rpc.NewDRPCFSClient(c.conn)} } +// Close closes the client connection func (c *Client) Close() error { return c.conn.Close() } diff --git a/api/drpc.go b/api/drpc.go index cfbf941..9f0988b 100644 --- a/api/drpc.go +++ b/api/drpc.go @@ -11,6 +11,8 @@ import ( var _ drpc.Conn = &muxConn{} +// muxConn implements drpc.Conn using the yamux +// multiplexer to allow concurrent RPCs type muxConn struct { conn io.ReadWriteCloser sess *yamux.Session