本文整理汇总了Golang中github.com/juju/juju/state.MetricsManager.SetLastSuccessfulSend方法的典型用法代码示例。如果您正苦于以下问题:Golang MetricsManager.SetLastSuccessfulSend方法的具体用法?Golang MetricsManager.SetLastSuccessfulSend怎么用?Golang MetricsManager.SetLastSuccessfulSend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state.MetricsManager
的用法示例。
在下文中一共展示了MetricsManager.SetLastSuccessfulSend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: assertMetricsManagerAmberState
func assertMetricsManagerAmberState(c *gc.C, metricsManager *state.MetricsManager) {
err := metricsManager.SetLastSuccessfulSend(time.Now())
c.Assert(err, jc.ErrorIsNil)
for i := 0; i < 3; i++ {
err := metricsManager.IncrementConsecutiveErrors()
c.Assert(err, jc.ErrorIsNil)
}
status := metricsManager.MeterStatus()
c.Assert(status.Code, gc.Equals, state.MeterAmber)
}
示例2: assertMetricsManagerRedState
// TODO (mattyw) This function could be moved into a metricsmanager testing package.
func assertMetricsManagerRedState(c *gc.C, metricsManager *state.MetricsManager) {
// To enter the red state we need to set a last successful send as over 1 week ago
err := metricsManager.SetLastSuccessfulSend(time.Now().Add(-8 * 24 * time.Hour))
c.Assert(err, jc.ErrorIsNil)
for i := 0; i < 3; i++ {
err := metricsManager.IncrementConsecutiveErrors()
c.Assert(err, jc.ErrorIsNil)
}
status := metricsManager.MeterStatus()
c.Assert(status.Code, gc.Equals, state.MeterRed)
}