本文整理汇总了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;未经允许,请勿转载。 |
请发表评论