send registers op with the dispatch loop, then sends msg on the connection. if sending fails, op is deregistered.
(ctx context.Context, op *requestOp, msg interface{})
| 457 | // send registers op with the dispatch loop, then sends msg on the connection. |
| 458 | // if sending fails, op is deregistered. |
| 459 | func (c *Client) send(ctx context.Context, op *requestOp, msg interface{}) error { |
| 460 | select { |
| 461 | case c.requestOp <- op: |
| 462 | log.Debug("", "msg", func() string { |
| 463 | return fmt.Sprint("sending ", msg) |
| 464 | }()) |
| 465 | err := c.write(ctx, msg) |
| 466 | c.sendDone <- err |
| 467 | return err |
| 468 | case <-ctx.Done(): |
| 469 | // This can happen if the client is overloaded or unable to keep up with |
| 470 | // subscription notifications. |
| 471 | return ctx.Err() |
| 472 | case <-c.didQuit: |
| 473 | return ErrClientQuit |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | func (c *Client) write(ctx context.Context, msg interface{}) error { |
| 478 | deadline, ok := ctx.Deadline() |
no test coverage detected