本文整理匯總了Golang中github.com/tsuru/tsuru/event.Event.EndData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Event.EndData方法的具體用法?Golang Event.EndData怎麽用?Golang Event.EndData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/event.Event
的用法示例。
在下文中一共展示了Event.EndData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: toAutoScaleEvent
func toAutoScaleEvent(evt *event.Event) (autoScaleEvent, error) {
var data evtCustomData
err := evt.EndData(&data)
if err != nil {
return autoScaleEvent{}, err
}
autoScaleEvt := autoScaleEvent{
ID: evt.UniqueID,
MetadataValue: evt.Target.Value,
Nodes: data.Nodes,
StartTime: evt.StartTime,
EndTime: evt.EndTime,
Successful: evt.Error == "",
Error: evt.Error,
Log: evt.Log,
}
if data.Result != nil {
if data.Result.ToAdd > 0 {
autoScaleEvt.Action = scaleActionAdd
} else if len(data.Result.ToRemove) > 0 {
autoScaleEvt.Action = scaleActionRemove
} else if data.Result.ToRebalance {
autoScaleEvt.Action = scaleActionRebalance
}
autoScaleEvt.Reason = data.Result.Reason
}
return autoScaleEvt, nil
}
示例2: toHealingEvt
func toHealingEvt(evt *event.Event) (HealingEvent, error) {
healingEvt := HealingEvent{
ID: evt.UniqueID,
StartTime: evt.StartTime,
EndTime: evt.EndTime,
Action: fmt.Sprintf("%s-healing", evt.Target.Type),
Successful: evt.Error == "",
Error: evt.Error,
}
switch evt.Target.Type {
case event.TargetTypeContainer:
err := evt.StartData(&healingEvt.FailingContainer)
if err != nil {
return healingEvt, err
}
err = evt.EndData(&healingEvt.CreatedContainer)
if err != nil {
return healingEvt, err
}
case event.TargetTypeNode:
var data healer.NodeHealerCustomData
err := evt.StartData(&data)
if err != nil {
return healingEvt, err
}
if data.LastCheck != nil {
healingEvt.Extra = data.LastCheck
}
healingEvt.Reason = data.Reason
healingEvt.FailingNode = data.Node
var createdNode provision.NodeSpec
err = evt.EndData(&createdNode)
if err != nil {
return healingEvt, err
}
healingEvt.CreatedNode = createdNode
}
return healingEvt, nil
}
示例3: eventToDeployData
func eventToDeployData(evt *event.Event, validImages set.Set, full bool) *DeployData {
data := &DeployData{
ID: evt.UniqueID,
App: evt.Target.Value,
Timestamp: evt.StartTime,
Duration: evt.EndTime.Sub(evt.StartTime),
Error: evt.Error,
User: evt.Owner.Name,
}
var startOpts DeployOptions
err := evt.StartData(&startOpts)
if err == nil {
data.Commit = startOpts.Commit
data.Origin = startOpts.GetOrigin()
}
if full {
data.Log = evt.Log
var otherData map[string]string
err = evt.OtherData(&otherData)
if err == nil {
data.Diff = otherData["diff"]
}
}
var endData map[string]string
err = evt.EndData(&endData)
if err == nil {
data.Image = endData["image"]
if validImages != nil {
data.CanRollback = validImages.Includes(data.Image)
if reImageVersion.MatchString(data.Image) {
parts := reImageVersion.FindAllStringSubmatch(data.Image, -1)
data.Image = parts[0][0]
}
}
}
return data
}