MCPcopy Index your code
hub / github.com/koding/kite / RegisterForever

Method RegisterForever

kontrolclient.go:306–350  ·  view source on GitHub ↗

RegisterForever is equivalent to Register(), but it tries to re-register if there is a disconnection. The returned error is for the first register attempt. It returns nil if ReadNotify() is ready and it's registered successful.

(kiteURL *url.URL)

Source from the content-addressed store, hash-verified

304// attempt. It returns nil if ReadNotify() is ready and it's registered
305// successful.
306func (k *Kite) RegisterForever(kiteURL *url.URL) error {
307 errs := make(chan error, 1)
308 go func() {
309 for u := range k.kontrol.registerChan {
310 _, err := k.Register(u)
311 if err == nil {
312 k.kontrol.Lock()
313 k.kontrol.lastRegisteredURL = u
314 k.kontrol.Unlock()
315 k.signalReady()
316 continue
317 }
318
319 select {
320 case errs <- err:
321 default:
322 }
323
324 k.Log.Error("Cannot register to Kontrol: %s Will retry after %d seconds",
325 err, kontrolRetryDuration/time.Second)
326
327 time.AfterFunc(kontrolRetryDuration, func() {
328 select {
329 case k.kontrol.registerChan <- u:
330 default:
331 }
332 })
333 }
334 }()
335
336 // don't block if there the given url is nil
337 if kiteURL == nil {
338 return nil
339 }
340
341 // initiate a registiration if a url is given
342 k.kontrol.registerChan <- kiteURL
343
344 select {
345 case <-k.KontrolReadyNotify():
346 return nil
347 case err := <-errs:
348 return err
349 }
350}
351
352// Register registers current Kite to Kontrol. After registration other Kites
353// can find it via GetKites() or WatchKites() method. This method does not

Callers 10

RegisterToProxyMethod · 0.95
TestWebSocketProxyFunction · 0.80
mainFunction · 0.80
RegisterMethod · 0.80
TestMultipleFunction · 0.80
TestKontrolFunction · 0.80
TestKontrolMultiKeyFunction · 0.80
TestRegisterToKontrolFunction · 0.80
listenAndServeMethod · 0.80
mainFunction · 0.80

Calls 4

RegisterMethod · 0.95
signalReadyMethod · 0.95
KontrolReadyNotifyMethod · 0.95
ErrorMethod · 0.65

Tested by 6

TestWebSocketProxyFunction · 0.64
RegisterMethod · 0.64
TestMultipleFunction · 0.64
TestKontrolFunction · 0.64
TestKontrolMultiKeyFunction · 0.64
TestRegisterToKontrolFunction · 0.64