Await waits for (and decodes) the results of a Call. The response will be unmarshaled from JSON into the result. If the call is cancelled due to context cancellation, the result is ctx.Err().
(ctx context.Context, result any)
| 397 | // If the call is cancelled due to context cancellation, the result is |
| 398 | // ctx.Err(). |
| 399 | func (ac *AsyncCall) Await(ctx context.Context, result any) error { |
| 400 | select { |
| 401 | case <-ctx.Done(): |
| 402 | return ctx.Err() |
| 403 | case <-ac.ready: |
| 404 | } |
| 405 | if ac.response.Error != nil { |
| 406 | return ac.response.Error |
| 407 | } |
| 408 | if result == nil { |
| 409 | return nil |
| 410 | } |
| 411 | return json.Unmarshal(ac.response.Result, result) |
| 412 | } |
| 413 | |
| 414 | // Cancel cancels the Context passed to the Handle call for the inbound message |
| 415 | // with the given ID. |