本文整理汇总了Golang中github.com/juju/juju/state.MetricsManager类的典型用法代码示例。如果您正苦于以下问题:Golang MetricsManager类的具体用法?Golang MetricsManager怎么用?Golang MetricsManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetricsManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleResponse
func handleResponse(mm *state.MetricsManager, st ModelBackend, response wireformat.Response) int {
var acknowledgedBatches int
for _, envResp := range response.EnvResponses {
acknowledgedBatches += len(envResp.AcknowledgedBatches)
err := st.SetMetricBatchesSent(envResp.AcknowledgedBatches)
if err != nil {
logger.Errorf("failed to set sent on metrics %v", err)
}
for unitName, status := range envResp.UnitStatuses {
unit, err := st.Unit(unitName)
if err != nil {
logger.Errorf("failed to retrieve unit %q: %v", unitName, err)
continue
}
err = unit.SetMeterStatus(status.Status, status.Info)
if err != nil {
logger.Errorf("failed to set unit %q meter status to %v: %v", unitName, status, err)
}
}
}
if response.NewGracePeriod > 0 {
err := mm.SetGracePeriod(response.NewGracePeriod)
if err != nil {
logger.Errorf("failed to set new grace period %v", err)
}
}
return acknowledgedBatches
}
开发者ID:kat-co,项目名称:juju,代码行数:28,代码来源:metricsender.go
示例2: 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)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:meterstatus_test.go
示例3: 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)
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:meterstatus_test.go
注:本文中的github.com/juju/juju/state.MetricsManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论