MCPcopy Index your code
hub / github.com/coder/coder / NewClient

Function NewClient

agent/agentsocket/client.go:42–60  ·  view source on GitHub ↗

NewClient creates a new socket client and opens a connection to the socket. If path is not provided via WithPath or is empty, it will auto-discover the default socket path.

(ctx context.Context, opts ...Option)

Source from the content-addressed store, hash-verified

40// If path is not provided via WithPath or is empty, it will auto-discover the
41// default socket path.
42func NewClient(ctx context.Context, opts ...Option) (*Client, error) {
43 options := &options{}
44 for _, opt := range opts {
45 opt(options)
46 }
47
48 conn, err := dialSocket(ctx, options.path)
49 if err != nil {
50 return nil, xerrors.Errorf("connect to socket: %w", err)
51 }
52
53 drpcConn := drpcconn.New(conn)
54 client := proto.NewDRPCAgentSocketClient(drpcConn)
55
56 return &Client{
57 client: client,
58 conn: drpcConn,
59 }, nil
60}
61
62// Close closes the socket connection.
63func (c *Client) Close() error {

Callers 8

syncStartMethod · 0.92
syncCompleteMethod · 0.92
syncStatusMethod · 0.92
syncPingMethod · 0.92
syncWantMethod · 0.92
mcpServerMethod · 0.92
TestSyncCommands_GoldenFunction · 0.92
newSocketClientFunction · 0.92

Calls 3

dialSocketFunction · 0.70
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by 2

TestSyncCommands_GoldenFunction · 0.74
newSocketClientFunction · 0.74