本文整理汇总了Golang中fullerite/handler.Handler类的典型用法代码示例。如果您正苦于以下问题:Golang Handler类的具体用法?Golang Handler怎么用?Golang Handler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Handler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: checkEmission
func checkEmission(t *testing.T, coll string, h handler.Handler, expected bool) {
m := metric.Metric{
Name: "test",
Value: 1,
Dimensions: map[string]string{"collector": coll},
}
writeToHandlers([]handler.Handler{h}, m)
_, ok := h.CollectorEndpoints()[coll]
if !expected && ok {
assert.Fail(t, fmt.Sprintf("Was not expecting a collector channel for %s", coll))
}
if expected && !ok {
assert.Fail(t, fmt.Sprintf("Was expecting a collector channel for %s", coll))
}
}
开发者ID:Yelp,项目名称:fullerite,代码行数:15,代码来源:handlers_test.go
示例2: checkEmission
func checkEmission(t *testing.T, coll string, h handler.Handler, expected bool) {
m := metric.Metric{
Name: "test",
Value: 1,
Dimensions: map[string]string{"collector": coll},
}
writeToHandlers([]handler.Handler{h}, m)
select {
case res := <-h.Channel():
if !expected {
assert.Fail(t, fmt.Sprintf("Did not expect metric %s", res.Name))
}
default:
if expected {
assert.Fail(t, "Was expecting the metric to go through")
}
}
}
开发者ID:sagar8192,项目名称:fullerite,代码行数:19,代码来源:handlers_test.go
示例3: canSendMetric
func canSendMetric(handler handler.Handler, metric metric.Metric) bool {
// If the handler's whitelist is set, then only metrics from collectors in it will be emitted. If the same
// collector is also in the blacklist, it will be skipped.
// If the handler's whitelist is not set and its blacklist is not empty, only metrics from collectors not in
// the blacklist will be emitted.
value, _ := metric.GetDimensionValue("collector")
isWhiteListed, _ := handler.IsCollectorWhiteListed(value)
isBlackListed, _ := handler.IsCollectorBlackListed(value)
// If the handler's whitelist is not nil and not empty, only the whitelisted collectors should be considered
if handler.CollectorWhiteList() != nil && len(handler.CollectorWhiteList()) > 0 {
if isWhiteListed && !isBlackListed {
return true
}
return false
}
// If the handler's whitelist is nil, all collector except the ones in the blacklist are enabled
if !isBlackListed {
return true
}
return false
}
开发者ID:carriercomm,项目名称:fullerite,代码行数:23,代码来源:handlers.go
示例4: sendMetrics
func sendMetrics(handler handler.Handler, metrics []metric.Metric) {
for _, m := range metrics {
handler.Channel() <- m
}
}
开发者ID:sagar8192,项目名称:fullerite,代码行数:5,代码来源:main.go
注:本文中的fullerite/handler.Handler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论