(ctx context.Context, sentinel string, timeout time.Duration, fn func(client *Client) error)
| 85 | } |
| 86 | |
| 87 | func (s *Sentinel) dispatch(ctx context.Context, sentinel string, timeout time.Duration, |
| 88 | fn func(client *Client) error) error { |
| 89 | c, err := NewClientNoAuth(sentinel, timeout) |
| 90 | if err != nil { |
| 91 | return err |
| 92 | } |
| 93 | defer c.Close() |
| 94 | |
| 95 | var exit = make(chan error, 1) |
| 96 | |
| 97 | go func() { |
| 98 | exit <- fn(c) |
| 99 | }() |
| 100 | |
| 101 | select { |
| 102 | case <-ctx.Done(): |
| 103 | return errors.Trace(ctx.Err()) |
| 104 | case err := <-exit: |
| 105 | return err |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func (s *Sentinel) subscribeCommand(client *Client, sentinel string, |
| 110 | onSubscribed func()) error { |
no test coverage detected