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


Golang bucket.Id類代碼示例

本文整理匯總了Golang中github.com/ryandotsmith/l2met/bucket.Id的典型用法代碼示例。如果您正苦於以下問題:Golang Id類的具體用法?Golang Id怎麽用?Golang Id使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Id類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: handleHkRouter

func (p *parser) handleHkRouter(t *tuple) error {
	if string(p.lr.Header().Procid) != routerPrefix {
		return nil
	}
	id := new(bucket.Id)
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Source = p.ld.Source()
	id.Units = t.Units()
	switch t.Name() {
	case "bytes":
		id.Name = p.Prefix("router.bytes")
	case "connect":
		id.Name = p.Prefix("router.connect")
	case "service":
		id.Name = p.Prefix("router.service")
	default:
		return nil
	}
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
開發者ID:sclasen,項目名稱:l2met,代碼行數:28,代碼來源:parser.go

示例2: handleCounters

func (p *parser) handleCounters(t *tuple) error {
	if !strings.HasPrefix(t.Name(), counterPrefix) {
		return nil
	}
	id := new(bucket.Id)
	p.buildId(id, t)
	id.Type = "counter"
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
開發者ID:ryandotsmith,項目名稱:l2met,代碼行數:14,代碼來源:parser.go

示例3: handleLegacyMeasurements

func (p *parser) handleLegacyMeasurements(t *tuple) error {
	if !strings.HasPrefix(t.Name(), legacyPrefix) {
		return nil
	}
	id := new(bucket.Id)
	p.buildId(id, t)
	id.Type = "measurement"
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
開發者ID:ryandotsmith,項目名稱:l2met,代碼行數:14,代碼來源:parser.go

示例4: putback

func (s *RedisStore) putback(id *bucket.Id) error {
	defer utils.MeasureT("bucket.putback", time.Now())
	rc := s.redisPool.Get()
	defer rc.Close()
	key := id.Encode()
	partition := s.bucketPartition([]byte(key))
	rc.Send("MULTI")
	rc.Send("SADD", partition, key)
	rc.Send("EXPIRE", partition, 300)
	_, err := rc.Do("EXEC")
	if err != nil {
		return err
	}
	return nil
}
開發者ID:pjvds,項目名稱:l2met,代碼行數:15,代碼來源:redis_store.go

示例5: Scan

func (s *RedisStore) Scan(schedule time.Time) (<-chan *bucket.Bucket, error) {
	retBuckets := make(chan *bucket.Bucket)
	p, err := s.lockPartition()
	if err != nil {
		return retBuckets, err
	}
	partition := partitionPrefix + "." + strconv.Itoa(int(p))
	go func(out chan *bucket.Bucket) {
		rc := s.redisPool.Get()
		defer rc.Close()
		defer close(out)
		defer s.unlockPartition(p)
		rc.Send("MULTI")
		rc.Send("SMEMBERS", partition)
		rc.Send("DEL", partition)
		reply, err := redis.Values(rc.Do("EXEC"))
		if err != nil {
			fmt.Printf("at=%q error=%s\n", "bucket-store-scan", err)
			return
		}
		var delCount int64
		var members []string
		redis.Scan(reply, &members, &delCount)
		for _, member := range members {
			id := new(bucket.Id)
			err := id.Decode(bytes.NewBufferString(member))
			if err != nil {
				fmt.Printf("at=%q error=%s\n",
					"bucket-store-parse-key", err)
				continue
			}
			bucketReady := id.Time.Add(id.Resolution)
			if !bucketReady.After(schedule) {
				out <- &bucket.Bucket{Id: id}
			} else {
				if err := s.putback(id); err != nil {
					fmt.Printf("putback-error=%s\n", err)
				}
			}
		}
	}(retBuckets)
	return retBuckets, nil
}
開發者ID:BRMatt,項目名稱:l2met,代碼行數:43,代碼來源:redis_store.go

示例6: testBucket

func testBucket(name, source, user, pass string, t time.Time, res time.Duration, vals []float64) *bucket.Bucket {
	id := new(bucket.Id)
	id.Name = name
	id.Source = source
	id.User = user
	id.Pass = pass
	id.Time = t.Truncate(res)
	id.Resolution = res
	return &bucket.Bucket{Id: id, Vals: vals}
}
開發者ID:Jwpe,項目名稱:l2met,代碼行數:10,代碼來源:receiver_test.go

示例7: buildId

func (p *parser) buildId(id *bucket.Id, t *tuple) {
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.Auth = p.Auth()
	id.ReadyAt = id.Time.Add(id.Resolution).Truncate(id.Resolution)
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.SourcePrefix(p.ld.Source())
	return
}
開發者ID:ryandotsmith,項目名稱:l2met,代碼行數:10,代碼來源:parser.go

示例8: buildId

func (p *parser) buildId(id *bucket.Id, t *tuple) {
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.ld.Source()
	return
}
開發者ID:Jwpe,項目名稱:l2met,代碼行數:10,代碼來源:parser.go

示例9: handleHkRouter

func (p *parser) handleHkRouter(t *tuple) error {
	if string(p.lr.Header().Procid) != routerPrefix {
		return nil
	}
	id := new(bucket.Id)
	p.buildId(id, t)
	id.Type = "measurement"
	switch t.Name() {
	case "bytes":
		id.Name = p.Prefix("router.bytes")
	case "connect":
		id.Name = p.Prefix("router.connect")
	case "service":
		id.Name = p.Prefix("router.service")
	default:
		return nil
	}
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
開發者ID:ryandotsmith,項目名稱:l2met,代碼行數:24,代碼來源:parser.go

示例10: handlMeasurements

func (p *parser) handlMeasurements(t *tuple) error {
	if !strings.HasPrefix(t.Name(), measurePrefix) {
		return nil
	}
	id := new(bucket.Id)
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.ld.Source()
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
開發者ID:sclasen,項目名稱:l2met,代碼行數:19,代碼來源:parser.go


注:本文中的github.com/ryandotsmith/l2met/bucket.Id類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。