本文整理汇总了Golang中github.com/koding/kite/protocol.Kite类的典型用法代码示例。如果您正苦于以下问题:Golang Kite类的具体用法?Golang Kite怎么用?Golang Kite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kite类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: insertKiteQuery
// inseryKiteQuery inserts the given kite, url and key to the kite.kite table
func insertKiteQuery(kiteProt *protocol.Kite, url, keyId string) (string, []interface{}, error) {
psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar)
kiteValues := kiteProt.Values()
values := make([]interface{}, len(kiteValues))
for i, kiteVal := range kiteValues {
values[i] = kiteVal
}
values = append(values, url)
values = append(values, keyId)
return psql.Insert("kite.kite").Columns(
"username",
"environment",
"kitename",
"version",
"region",
"hostname",
"id",
"url",
"key_id",
).Values(values...).ToSql()
}
开发者ID:GregWilson,项目名称:kite,代码行数:26,代码来源:postgres.go
示例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
}
开发者ID:gotao,项目名称:kite,代码行数:33,代码来源:etcd.go
示例3: 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
}
开发者ID:gotao,项目名称:kite,代码行数:26,代码来源:etcd.go
示例4: 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
}
开发者ID:gotao,项目名称:kite,代码行数:8,代码来源:etcd.go
示例5: validateKiteKey
// validateKiteKey returns a string representing the kite uniquely
// that is suitable to use as a key for etcd.
func validateKiteKey(k *protocol.Kite) error {
fields := k.Query().Fields()
// Validate fields.
for k, v := range fields {
if v == "" {
return fmt.Errorf("Empty Kite field: %s", k)
}
if strings.ContainsRune(v, '/') {
return fmt.Errorf("Field \"%s\" must not contain '/'", k)
}
}
return nil
}
开发者ID:gotao,项目名称:kite,代码行数:17,代码来源:etcd.go
注:本文中的github.com/koding/kite/protocol.Kite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论