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)
| 163 | // The context is used to cancel or time out the initial connection establishment. It does |
| 164 | // not affect subsequent interactions with the client. |
| 165 | func 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 | |
| 184 | type StdIOConn struct{} |
| 185 |