TellKontrolWithTimeout is a lower level function for communicating directly with kontrol. Like GetKites and GetToken, this automatically sets up and connects to kontrol as needed.
(method string, timeout time.Duration, args ...interface{})
| 510 | // kontrol. Like GetKites and GetToken, this automatically sets up and connects to |
| 511 | // kontrol as needed. |
| 512 | func (k *Kite) TellKontrolWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error) { |
| 513 | if err := k.SetupKontrolClient(); err != nil { |
| 514 | return nil, err |
| 515 | } |
| 516 | |
| 517 | // Wait for readyConnect, or timeout |
| 518 | select { |
| 519 | case <-time.After(k.Config.Timeout): |
| 520 | return nil, &Error{ |
| 521 | Type: "timeout", |
| 522 | Message: fmt.Sprintf( |
| 523 | "Timed out registering to kontrol for %s method after %s", |
| 524 | method, k.Config.Timeout, |
| 525 | ), |
| 526 | } |
| 527 | case <-k.kontrol.readyConnected: |
| 528 | } |
| 529 | |
| 530 | return k.kontrol.TellWithTimeout(method, timeout, args...) |
| 531 | } |