当前位置: 首页>>代码示例>>Golang>>正文


Golang Event.FormattedTime方法代码示例

本文整理汇总了Golang中github.com/Cepave/common/model.Event.FormattedTime方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.FormattedTime方法的具体用法?Golang Event.FormattedTime怎么用?Golang Event.FormattedTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Cepave/common/model.Event的用法示例。


在下文中一共展示了Event.FormattedTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: BuildCommonSMSContent

func BuildCommonSMSContent(event *model.Event) string {
	return fmt.Sprintf(
		"[P%d][%s][%s][][%s %s %s %s %s%s%s][O%d %s]",
		event.Priority(),
		event.Status,
		event.Endpoint,
		event.Note(),
		event.Func(),
		event.Metric(),
		utils.SortedTags(event.PushedTags),
		utils.ReadableFloat(event.LeftValue),
		event.Operator(),
		utils.ReadableFloat(event.RightValue()),
		event.CurrentStep,
		event.FormattedTime(),
	)
}
开发者ID:myhung,项目名称:alarm,代码行数:17,代码来源:builder.go

示例2: Callback

func Callback(event *model.Event, action *api.Action) string {
	if action.Url == "" {
		return "callback url is blank"
	}

	L := make([]string, 0)
	if len(event.PushedTags) > 0 {
		for k, v := range event.PushedTags {
			L = append(L, fmt.Sprintf("%s:%s", k, v))
		}
	}

	tags := ""
	if len(L) > 0 {
		tags = strings.Join(L, ",")
	}

	req := httplib.Get(action.Url).SetTimeout(3*time.Second, 20*time.Second)

	req.Param("endpoint", event.Endpoint)
	req.Param("metric", event.Metric())
	req.Param("func", event.Func())
	req.Param("leftValue", fmt.Sprintf("%.3f", event.LeftValue))
	req.Param("operator", event.Operator())
	req.Param("rightValue", fmt.Sprintf("%.3f", event.RightValue()))
	req.Param("note", event.Note())
	req.Param("status", event.Status)
	req.Param("step", fmt.Sprintf("%d", event.CurrentStep))
	req.Param("priority", fmt.Sprintf("%d", event.Priority()))
	req.Param("time", event.FormattedTime())
	req.Param("tpl_id", fmt.Sprintf("%d", event.TplId()))
	req.Param("exp_id", fmt.Sprintf("%d", event.ExpressionId()))
	req.Param("stra_id", fmt.Sprintf("%d", event.StrategyId()))
	req.Param("tags", tags)

	resp, e := req.String()

	success := "success"
	if e != nil {
		success = fmt.Sprintf("fail:%s", e.Error())
	}
	message := fmt.Sprintf("curl %s %s. resp: %s", action.Url, success, resp)

	return message
}
开发者ID:myhung,项目名称:alarm,代码行数:45,代码来源:callback.go

示例3: 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,
	)
}
开发者ID:myhung,项目名称:alarm,代码行数:20,代码来源:builder.go

示例4: 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&nbsp;</td>
                                        <td %s >%d&nbsp;</td></tr>
                                <tr>
                                        <td %s>Endpoint:</td>
                                        <td %s>%s&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Metric:</td>
                                        <td %s>%s&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Tags:</td>
                                        <td %s>%s&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>%s</td>
                                        <td %s>%s%s%s&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Note:</td>
                                        <td %s>%s&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Max:</td>
                                        <td %s>%d&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Current:</td>
                                        <td %s>%d&nbsp;</td>
                                </tr>
                                <tr>
                                        <td %s>Timesramp:</td>
                                        <td %s>%s&nbsp;</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,
	)
}
开发者ID:myhung,项目名称:alarm,代码行数:63,代码来源:builder.go


注:本文中的github.com/Cepave/common/model.Event.FormattedTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。