Better naming for rpc client and ssh session
This commit is contained in:
parent
fddcd876b0
commit
a99d0f5495
3 changed files with 13 additions and 13 deletions
14
client.go
14
client.go
|
|
@ -10,8 +10,8 @@ import (
|
|||
type Client struct {
|
||||
connection Connection
|
||||
|
||||
sshSession *sshSession
|
||||
rpc *rpc
|
||||
ssh *sshSession
|
||||
rpc *rpcClient
|
||||
}
|
||||
|
||||
type ClientOption func(*Client) error
|
||||
|
|
@ -45,12 +45,12 @@ func (c *Client) Join(ctx context.Context) (err error) {
|
|||
return fmt.Errorf("error connecting websocket: %v", err)
|
||||
}
|
||||
|
||||
c.sshSession = newSSH(c.connection.SessionToken, clientSocket)
|
||||
if err := c.sshSession.connect(ctx); err != nil {
|
||||
c.ssh = newSshSession(c.connection.SessionToken, clientSocket)
|
||||
if err := c.ssh.connect(ctx); err != nil {
|
||||
return fmt.Errorf("error connecting to ssh session: %v", err)
|
||||
}
|
||||
|
||||
c.rpc = newRPC(c.sshSession)
|
||||
c.rpc = newRpcClient(c.ssh)
|
||||
c.rpc.connect(ctx)
|
||||
|
||||
_, err = c.joinWorkspace(ctx)
|
||||
|
|
@ -62,7 +62,7 @@ func (c *Client) Join(ctx context.Context) (err error) {
|
|||
}
|
||||
|
||||
func (c *Client) hasJoined() bool {
|
||||
return c.sshSession != nil && c.rpc != nil
|
||||
return c.ssh != nil && c.rpc != nil
|
||||
}
|
||||
|
||||
type clientCapabilities struct {
|
||||
|
|
@ -105,7 +105,7 @@ func (c *Client) openStreamingChannel(ctx context.Context, streamName, condition
|
|||
return nil, fmt.Errorf("error getting stream id: %v", err)
|
||||
}
|
||||
|
||||
channel, reqs, err := c.sshSession.conn.OpenChannel("session", nil)
|
||||
channel, reqs, err := c.ssh.conn.OpenChannel("session", nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error opening ssh channel for transport: %v", err)
|
||||
}
|
||||
|
|
|
|||
10
rpc.go
10
rpc.go
|
|
@ -9,22 +9,22 @@ import (
|
|||
"github.com/sourcegraph/jsonrpc2"
|
||||
)
|
||||
|
||||
type rpc struct {
|
||||
type rpcClient struct {
|
||||
*jsonrpc2.Conn
|
||||
conn io.ReadWriteCloser
|
||||
handler *rpcHandler
|
||||
}
|
||||
|
||||
func newRPC(conn io.ReadWriteCloser) *rpc {
|
||||
return &rpc{conn: conn, handler: newRPCHandler()}
|
||||
func newRpcClient(conn io.ReadWriteCloser) *rpcClient {
|
||||
return &rpcClient{conn: conn, handler: newRPCHandler()}
|
||||
}
|
||||
|
||||
func (r *rpc) connect(ctx context.Context) {
|
||||
func (r *rpcClient) connect(ctx context.Context) {
|
||||
stream := jsonrpc2.NewBufferedStream(r.conn, jsonrpc2.VSCodeObjectCodec{})
|
||||
r.Conn = jsonrpc2.NewConn(ctx, stream, r.handler)
|
||||
}
|
||||
|
||||
func (r *rpc) do(ctx context.Context, method string, args interface{}, result interface{}) error {
|
||||
func (r *rpcClient) do(ctx context.Context, method string, args interface{}, result interface{}) error {
|
||||
waiter, err := r.Conn.DispatchCall(ctx, method, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error on dispatch call: %v", err)
|
||||
|
|
|
|||
2
ssh.go
2
ssh.go
|
|
@ -19,7 +19,7 @@ type sshSession struct {
|
|||
writer io.Writer
|
||||
}
|
||||
|
||||
func newSSH(token string, socket net.Conn) *sshSession {
|
||||
func newSshSession(token string, socket net.Conn) *sshSession {
|
||||
return &sshSession{token: token, socket: socket}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue