本文整理汇总了Golang中github.com/Cepave/common/model.Event.MaxStep方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.MaxStep方法的具体用法?Golang Event.MaxStep怎么用?Golang Event.MaxStep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Cepave/common/model.Event
的用法示例。
在下文中一共展示了Event.MaxStep方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Put
func (this *SafeEvents) Put(event *model.Event) {
if event.Status == "OK" {
this.Delete(event.Id)
return
}
dto := &EventDto{}
dto.Id = event.Id
dto.Endpoint = event.Endpoint
dto.Metric = event.Metric()
dto.Counter = event.Counter()
dto.Func = event.Func()
dto.LeftValue = utils.ReadableFloat(event.LeftValue)
dto.Operator = event.Operator()
dto.RightValue = utils.ReadableFloat(event.RightValue())
dto.Note = event.Note()
dto.MaxStep = event.MaxStep()
dto.CurrentStep = event.CurrentStep
dto.Priority = event.Priority()
dto.Status = event.Status
dto.Timestamp = event.EventTime
dto.ExpressionId = event.ExpressionId()
dto.StrategyId = event.StrategyId()
dto.TemplateId = event.TplId()
dto.Link = Link(event)
this.Lock()
defer this.Unlock()
this.M[dto.Id] = dto
}
示例2: BuildCommonQQContent
func BuildCommonQQContent(event *model.Event) string {
link := g.Link(event)
return fmt.Sprintf(
"%s\r\nP%d\r\nEndpoint:%s\r\nMetric:%s\r\nTags:%s\r\n%s: %s%s%s\r\nNote:%s\r\nMax:%d, Current:%d\r\nTimestamp:%s\r\n%s\r\n",
event.Status,
event.Priority(),
event.Endpoint,
event.Metric(),
utils.SortedTags(event.PushedTags),
event.Func(),
utils.ReadableFloat(event.LeftValue),
event.Operator(),
utils.ReadableFloat(event.RightValue()),
event.Note(),
event.MaxStep(),
event.CurrentStep,
event.FormattedTime(),
link,
)
}
示例3: BuildCommonMailContent
func BuildCommonMailContent(event *model.Event) string {
link := g.Link(event)
tdtl := `style="border: 1px solid #ccc; background: #FFF4F4;"`
tdtr := `style="border: 1px solid #ccc; border-left: none;"`
tdl := `style="border: 1px solid #ccc; border-top: none; background: #FFF4F4;"`
tdr := `style="border: 1px solid #ccc; border-top: none; border-left: none;"`
return fmt.Sprintf(
`<html><head><meta charset="utf-8"></head>
<body>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td %s >%s </td>
<td %s >%d </td></tr>
<tr>
<td %s>Endpoint:</td>
<td %s>%s </td>
</tr>
<tr>
<td %s>Metric:</td>
<td %s>%s </td>
</tr>
<tr>
<td %s>Tags:</td>
<td %s>%s </td>
</tr>
<tr>
<td %s>%s</td>
<td %s>%s%s%s </td>
</tr>
<tr>
<td %s>Note:</td>
<td %s>%s </td>
</tr>
<tr>
<td %s>Max:</td>
<td %s>%d </td>
</tr>
<tr>
<td %s>Current:</td>
<td %s>%d </td>
</tr>
<tr>
<td %s>Timesramp:</td>
<td %s>%s </td>
</tr>
</table>
<br>
<a href="%s">%s</a>
</body></html>`,
tdtl, event.Status, tdtr, event.Priority(),
tdl, tdr, event.Endpoint,
tdl, tdr, event.Metric(),
tdl, tdr, utils.SortedTags(event.PushedTags),
tdl, event.Func(), tdr, utils.ReadableFloat(event.LeftValue), event.Operator(), utils.ReadableFloat(event.RightValue()),
tdl, tdr, event.Note(),
tdl, tdr, event.MaxStep(),
tdl, tdr, event.CurrentStep,
tdl, tdr, event.FormattedTime(),
link,
link,
)
}
示例4: InsertEvent
func InsertEvent(eve *coommonModel.Event) {
log := logger.Logger()
q := orm.NewOrm()
q.Using("falcon_portal")
var event []EventCases
q.Raw("select * from event_cases where id = ?", eve.Id).QueryRows(&event)
if len(event) == 0 {
//create cases
sqltemplete := `INSERT INTO event_cases (
id,
endpoint,
metric,
func,
cond,
note,
max_step,
current_step,
priority,
status,
timestamp,
update_at,
tpl_creator,
expression_id,
strategy_id,
template_id
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
res1, err := q.Raw(
sqltemplete,
eve.Id,
eve.Endpoint,
counterGen(eve.Metric(), utils.SortedTags(eve.PushedTags)),
eve.Func(),
//cond
fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
eve.Strategy.Note,
eve.MaxStep(),
eve.CurrentStep,
eve.Priority(),
eve.Status,
//start_at
time.Unix(eve.EventTime, 0),
//update_at
time.Unix(eve.EventTime, 0),
eve.Strategy.Tpl.Creator,
eve.ExpressionId(),
eve.StrategyId(),
//template_id
eve.TplId()).Exec()
log.Debug(fmt.Sprintf("%v, %v", res1, err))
//insert case
res2, err := insertEvent(q, eve)
log.Debug(fmt.Sprintf("%v, %v", res2, err))
} else {
sqltemplete := `UPDATE event_cases SET
update_at = ?,
max_step = ?,
current_step = ?,
note = ?,
cond = ?,
status = ?`
//reopen case
if event[0].ProcessStatus == "resolved" || event[0].ProcessStatus == "ignored" {
sqltemplete = fmt.Sprintf("%v ,process_status = '%s', process_note = %d", sqltemplete, "unresolved", 0)
}
if eve.CurrentStep == 1 {
sqltemplete = fmt.Sprintf("%v ,timestamp = ? WHERE id = ?", sqltemplete)
//update start time of cases
res1, err := q.Raw(
sqltemplete,
time.Unix(eve.EventTime, 0),
eve.MaxStep(),
eve.CurrentStep,
eve.Strategy.Note,
fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
eve.Status,
time.Unix(eve.EventTime, 0),
eve.Id).Exec()
log.Debug(fmt.Sprintf("%v, %v", res1, err))
//insert case
res2, err := insertEvent(q, eve)
log.Debug(fmt.Sprintf("%v, %v", res2, err))
} else {
sqltemplete = fmt.Sprintf("%v WHERE id = ?", sqltemplete)
res1, err := q.Raw(
sqltemplete,
time.Unix(eve.EventTime, 0),
eve.MaxStep(),
eve.CurrentStep,
eve.Strategy.Note,
fmt.Sprintf("%v %v %v", eve.LeftValue, eve.Operator(), eve.RightValue()),
eve.Status,
eve.Id).Exec()
log.Debug(fmt.Sprintf("%v, %v", res1, err))
//insert case
res2, err := insertEvent(q, eve)
log.Debug(fmt.Sprintf("%v, %v", res2, err))
}
//.........这里部分代码省略.........