本文整理匯總了Golang中github.com/cloudfoundry/noaa/events.Envelope.GetHeartbeat方法的典型用法代碼示例。如果您正苦於以下問題:Golang Envelope.GetHeartbeat方法的具體用法?Golang Envelope.GetHeartbeat怎麽用?Golang Envelope.GetHeartbeat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/noaa/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetHeartbeat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Process
func (p *HeartbeatProcessor) Process(e *events.Envelope) []metrics.WMetric {
processedMetrics := make([]metrics.WMetric, 4)
heartbeat := e.GetHeartbeat()
origin := e.GetOrigin()
processedMetrics[0] = *p.ProcessHeartbeatCount(heartbeat, origin)
processedMetrics[1] = *p.ProcessHeartbeatEventsSentCount(heartbeat, origin)
processedMetrics[2] = *p.ProcessHeartbeatEventsReceivedCount(heartbeat, origin)
processedMetrics[3] = *p.ProcessHeartbeatEventsErrorCount(heartbeat, origin)
return processedMetrics
}
示例2: Heartbeat
func Heartbeat(msg *events.Envelope) Event {
heartbeat := msg.GetHeartbeat()
var avail uint64
if heartbeat.GetSentCount() > 0 {
avail = heartbeat.GetReceivedCount() / heartbeat.GetSentCount()
}
fields := logrus.Fields{
"ctl_msg_id": heartbeat.GetControlMessageIdentifier(),
"error_count": heartbeat.GetErrorCount(),
"origin": msg.GetOrigin(),
"received_count": heartbeat.GetReceivedCount(),
"sent_count": heartbeat.GetSentCount(),
"availability": avail,
}
return Event{
Fields: fields,
Msg: "",
Type: msg.GetEventType().String(),
}
}