本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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}
}
示例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
}
示例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
}
示例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
}
示例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
}