(ctx context.Context)
| 494 | } |
| 495 | |
| 496 | func (c *Client) reconnect(ctx context.Context) error { |
| 497 | newconn, err := c.connectFunc(ctx) |
| 498 | if err != nil { |
| 499 | log.Debug(fmt.Sprintf("reconnect failed: %v", err)) |
| 500 | return err |
| 501 | } |
| 502 | select { |
| 503 | case c.reconnected <- newconn: |
| 504 | c.writeConn = newconn |
| 505 | return nil |
| 506 | case <-c.didQuit: |
| 507 | newconn.Close() |
| 508 | return ErrClientQuit |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | // dispatch is the main loop of the client. |
| 513 | // It sends read messages to waiting calls to Call and BatchCall |