feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
53
internal/notifyrender/text_down_one.go
Обычный файл
53
internal/notifyrender/text_down_one.go
Обычный файл
@@ -0,0 +1,53 @@
|
||||
package notifyrender
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
)
|
||||
|
||||
var (
|
||||
// DownOneSubject provides functionality.
|
||||
DownOneSubject *template.Template
|
||||
// DownOneBody provides functionality.
|
||||
DownOneBody *template.Template
|
||||
// DownOneHTML provides functionality.
|
||||
DownOneHTML *template.Template
|
||||
)
|
||||
|
||||
func init() {
|
||||
DownOneSubject = template.Must(template.New("down_one_subject").Parse(`Не доступен {{.Monitor.GetLabel}}`))
|
||||
// DownOneBody provides functionality.
|
||||
DownOneBody = template.Must(template.New("down_one_body").Parse(`Монитор {{.Monitor.GetLabel}} не доступен :warning:
|
||||
|
||||
Проверки: {{.ChecksDown}}.
|
||||
Ошибка: {{.Reason}}
|
||||
|
||||
Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}
|
||||
|
||||
Недоступные проверки:
|
||||
{{range .Checks}}
|
||||
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
|
||||
{{end}}`))
|
||||
|
||||
DownOneHTML = template.Must(template.New("down_one_html").Parse(`<h4>Монитор {{.Monitor.GetLabel}} не доступен</h4>
|
||||
|
||||
Проверки: {{.ChecksDown}}.
|
||||
<h5 style='background-color: red;'>Ошибка:</h5>
|
||||
{{.Reason}}
|
||||
|
||||
<div>Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}</div>
|
||||
|
||||
<h5>Недоступные проверки:<h5>
|
||||
{{range .Checks}}
|
||||
<div>
|
||||
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
|
||||
</div>
|
||||
{{end}}`))
|
||||
}
|
||||
|
||||
// TextDownOne provides functionality.
|
||||
func TextDownOne(event *models.Event) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
|
||||
return executeTemplates(event, DownOneSubject, DownOneBody, DownOneHTML, " :warning:")
|
||||
}
|
||||
Ссылка в новой задаче
Block a user