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

Method GetKey

kontrolclient.go:254–277  ·  view source on GitHub ↗

GetKey is used to get a new public key from kontrol if the current one is invalidated. The key is also replaced in memory and every request is going to use it. This means even if kite.key contains the old key, the kite itself uses the new one.

()

Source from the content-addressed store, hash-verified

252// to use it. This means even if kite.key contains the old key, the kite itself
253// uses the new one.
254func (k *Kite) GetKey() (string, error) {
255 if err := k.SetupKontrolClient(); err != nil {
256 return "", err
257 }
258
259 <-k.kontrol.readyConnected
260
261 result, err := k.kontrol.TellWithTimeout("getKey", k.Config.Timeout)
262 if err != nil {
263 return "", err
264 }
265
266 var key string
267 err = result.Unmarshal(&key)
268 if err != nil {
269 return "", err
270 }
271
272 k.configMu.Lock()
273 k.Config.KontrolKey = key
274 k.configMu.Unlock()
275
276 return key, nil
277}
278
279// NewKeyRenewer renews the internal key every given interval
280func (k *Kite) NewKeyRenewer(interval time.Duration) {

Callers 2

NewKeyRenewerMethod · 0.95
TestKontrolMultiKeyFunction · 0.80

Calls 3

SetupKontrolClientMethod · 0.95
TellWithTimeoutMethod · 0.80
UnmarshalMethod · 0.80

Tested by 1

TestKontrolMultiKeyFunction · 0.64