wait blocks for the callback outcome or ctx cancellation, then shuts the server down. It is safe to call once per server.
(ctx context.Context)
| 124 | // wait blocks for the callback outcome or ctx cancellation, then shuts the |
| 125 | // server down. It is safe to call once per server. |
| 126 | func (cs *callbackServer) wait(ctx context.Context) (string, error) { |
| 127 | defer cs.close() |
| 128 | select { |
| 129 | case res := <-cs.results: |
| 130 | return res.code, res.err |
| 131 | case <-ctx.Done(): |
| 132 | return "", ctx.Err() |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func (cs *callbackServer) close() { |
| 137 | shutdownCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |