(initctx context.Context, connectFunc func(context.Context) (net.Conn, error))
| 221 | } |
| 222 | |
| 223 | func newClient(initctx context.Context, connectFunc func(context.Context) (net.Conn, error)) (*Client, error) { |
| 224 | conn, err := connectFunc(initctx) |
| 225 | if err != nil { |
| 226 | return nil, err |
| 227 | } |
| 228 | _, isHTTP := conn.(*httpConn) |
| 229 | c := &Client{ |
| 230 | writeConn: conn, |
| 231 | isHTTP: isHTTP, |
| 232 | connectFunc: connectFunc, |
| 233 | close: make(chan struct{}), |
| 234 | didQuit: make(chan struct{}), |
| 235 | reconnected: make(chan net.Conn), |
| 236 | readErr: make(chan error), |
| 237 | readResp: make(chan []*jsonrpcMessage), |
| 238 | requestOp: make(chan *requestOp), |
| 239 | sendDone: make(chan error, 1), |
| 240 | respWait: make(map[string]*requestOp), |
| 241 | subs: make(map[string]*ClientSubscription), |
| 242 | } |
| 243 | if !isHTTP { |
| 244 | go c.dispatch(conn) |
| 245 | } |
| 246 | return c, nil |
| 247 | } |
| 248 | |
| 249 | func (c *Client) nextID() json.RawMessage { |
| 250 | id := atomic.AddUint32(&c.idCounter, 1) |
no test coverage detected