MCPcopy Create free account
hub / github.com/CPChain/chain / DialContext

Function DialContext

api/rpc/client.go:165–182  ·  view source on GitHub ↗

DialContext creates a new RPC client, just like Dial. The context is used to cancel or time out the initial connection establishment. It does not affect subsequent interactions with the client.

(ctx context.Context, rawurl string)

Source from the content-addressed store, hash-verified

163// The context is used to cancel or time out the initial connection establishment. It does
164// not affect subsequent interactions with the client.
165func DialContext(ctx context.Context, rawurl string) (*Client, error) {
166 u, err := url.Parse(rawurl)
167 if err != nil {
168 return nil, err
169 }
170 switch u.Scheme {
171 case "http", "https":
172 return DialHTTP(rawurl)
173 case "ws", "wss":
174 return DialWebsocket(ctx, rawurl, "")
175 case "stdio":
176 return DialStdIO(ctx)
177 case "":
178 return DialIPC(ctx, rawurl)
179 default:
180 return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme)
181 }
182}
183
184type StdIOConn struct{}
185

Callers 2

TestClientReconnectFunction · 0.70
DialFunction · 0.70

Calls 4

DialHTTPFunction · 0.85
DialWebsocketFunction · 0.85
DialStdIOFunction · 0.85
DialIPCFunction · 0.85

Tested by 1

TestClientReconnectFunction · 0.56