本文整理匯總了Golang中github.com/mailgun/vulcan/request.Request.SetUserData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.SetUserData方法的具體用法?Golang Request.SetUserData怎麽用?Golang Request.SetUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mailgun/vulcan/request.Request
的用法示例。
在下文中一共展示了Request.SetUserData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkCondition
func (c *CircuitBreaker) checkCondition(r request.Request) bool {
if !c.timeToCheck() {
return false
}
c.m.Lock()
defer c.m.Unlock()
// Other goroutine could have updated the lastCheck variable before we grabbed mutex
if !c.tm.UtcNow().After(c.lastCheck) {
return false
}
c.lastCheck = c.tm.UtcNow().Add(c.checkPeriod)
// Each requests holds a context attached to it, we use it to attach the metrics to the request
// so condition checker function can use it for analysis on the next line.
r.SetUserData(cbreakerMetrics, c.metrics)
return c.condition(r)
}
示例2: markToRecordMetrics
func (c *CircuitBreaker) markToRecordMetrics(r request.Request) {
r.SetUserData(cbreakerRecordMetrics, true)
}