當前位置: 首頁>>代碼示例>>Golang>>正文


Golang protocol.Kite類代碼示例

本文整理匯總了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;未經允許,請勿轉載。