本文整理匯總了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)
}