本文整理汇总了Golang中github.com/square/metrics/api.TagSet类的典型用法代码示例。如果您正苦于以下问题:Golang TagSet类的具体用法?Golang TagSet怎么用?Golang TagSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TagSet类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RemoveMetricName
func (db *cassandraDatabase) RemoveMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
return db.session.Query(
"DELETE FROM metric_names WHERE metric_key = ? AND tag_set = ?",
metricKey,
tagSet.Serialize(),
).Exec()
}
示例2: RemoveMetricName
func (db *defaultDatabase) RemoveMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
db.allMetricsMutex.Lock()
// Forget the metric in the cache.
// (If this delete fails, there will be an extraneous write the next time the metric is consumed).
db.allMetricsCache[metricKey] = false
db.allMetricsMutex.Unlock()
return db.session.Query(
"DELETE FROM metric_names WHERE metric_key = ? AND tag_set = ?",
metricKey,
tagSet.Serialize(),
).Exec()
}
示例3: AddMetricName
// AddMetricName inserts to metric to Cassandra.
func (db *defaultDatabase) AddMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
if err := db.session.Query("INSERT INTO metric_names (metric_key, tag_set) VALUES (?, ?)", metricKey, tagSet.Serialize()).Exec(); err != nil {
return err
}
db.allMetricsMutex.Lock()
if db.allMetricsCache[metricKey] {
db.allMetricsMutex.Unlock()
// If the key is found in the cache, exit early.
return nil
}
db.allMetricsMutex.Unlock()
if err := db.session.Query("UPDATE metric_name_set SET metric_names = metric_names + ? WHERE shard = ?", []string{string(metricKey)}, 0).Exec(); err != nil {
return err
}
db.allMetricsMutex.Lock()
// Remember the cached value so that it won't be written again in the absence of reads.
db.allMetricsCache[metricKey] = true
db.allMetricsMutex.Unlock()
return nil
}
示例4: AddMetricName
// AddMetricName inserts to metric to Cassandra.
func (db *cassandraDatabase) AddMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
if err := db.session.Query("INSERT INTO metric_names (metric_key, tag_set) VALUES (?, ?)", metricKey, tagSet.Serialize()).Exec(); err != nil {
return err
}
if err := db.session.Query("UPDATE metric_name_set SET metric_names = metric_names + ? WHERE shard = ?", []string{string(metricKey)}, 0).Exec(); err != nil {
return err
}
return nil
}
示例5: matchPrecondition
func matchPrecondition(matcherTag string, tagSet api.TagSet) bool {
return tagSet.HasKey(matcherTag)
}