本文整理汇总了Golang中github.com/koding/kite/protocol.Kite.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Kite.String方法的具体用法?Golang Kite.String怎么用?Golang Kite.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/koding/kite/protocol.Kite
的用法示例。
在下文中一共展示了Kite.String方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Add
func (e *Etcd) Add(k *protocol.Kite, value *kontrolprotocol.RegisterValue) error {
etcdKey := KitesPrefix + k.String()
etcdIDKey := KitesPrefix + "/" + k.ID
valueBytes, err := json.Marshal(value)
if err != nil {
return err
}
valueString := string(valueBytes)
// Set the kite key.
// Example "/koding/production/os/0.0.1/sj/kontainer1.sj.koding.com/1234asdf..."
_, err = e.client.Set(etcdKey, valueString, uint64(KeyTTL/time.Second))
if err != nil {
return err
}
// Also store the the kite.Key Id for easy lookup
_, err = e.client.Set(etcdIDKey, valueString, uint64(KeyTTL/time.Second))
if err != nil {
return err
}
return nil
}
示例2: Update
func (e *Etcd) Update(k *protocol.Kite, value *kontrolprotocol.RegisterValue) error {
etcdKey := KitesPrefix + k.String()
etcdIDKey := KitesPrefix + "/" + k.ID
valueBytes, err := json.Marshal(value)
if err != nil {
return err
}
valueString := string(valueBytes)
// update the kite key.
// Example "/koding/production/os/0.0.1/sj/kontainer1.sj.koding.com/1234asdf..."
_, err = e.client.Update(etcdKey, valueString, uint64(KeyTTL/time.Second))
if err != nil {
return err
}
// Also update the the kite.Key Id for easy lookup
_, err = e.client.Update(etcdIDKey, valueString, uint64(KeyTTL/time.Second))
if err != nil {
return err
}
// Set the TTL for the username. Otherwise, empty dirs remain in etcd.
_, err = e.client.Update(KitesPrefix+"/"+k.Username,
"", uint64(KeyTTL/time.Second))
if err != nil {
return err
}
return nil
}
示例3: Delete
func (e *Etcd) Delete(k *protocol.Kite) error {
etcdKey := KitesPrefix + k.String()
etcdIDKey := KitesPrefix + "/" + k.ID
_, err := e.client.Delete(etcdKey, true)
_, err = e.client.Delete(etcdIDKey, true)
return err
}