feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
48
internal/notifyrender/text_expires.go
Обычный файл
48
internal/notifyrender/text_expires.go
Обычный файл
@@ -0,0 +1,48 @@
|
||||
package notifyrender
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
)
|
||||
|
||||
var (
|
||||
// ExpSubject provides functionality.
|
||||
ExpSubject *template.Template
|
||||
// ExpBody provides functionality.
|
||||
ExpBody *template.Template
|
||||
// ExpHTML provides functionality.
|
||||
ExpHTML *template.Template
|
||||
)
|
||||
|
||||
func init() {
|
||||
ExpSubject = template.Must(template.New("exp_subject").Parse(`Скоро истекает {{.GetLabel}} ({{.KindLabel}}) по {{.Monitor.GetLabel}}`))
|
||||
// ExpBody provides functionality.
|
||||
ExpBody = template.Must(template.New("exp_body").Parse(`Монитор {{.Monitor.GetLabel}}
|
||||
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} ({{.KindLabel}})
|
||||
`))
|
||||
ExpHTML = template.Must(template.New("exp_html").Parse(`Монитор {{.Monitor.GetLabel}}
|
||||
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} <strong>({{.KindLabel}})</strong>
|
||||
`))
|
||||
}
|
||||
|
||||
// TextExpires provides functionality.
|
||||
func TextExpires(check *models.Check) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
|
||||
var err error
|
||||
var subject, textBody, htmlBody bytes.Buffer
|
||||
|
||||
err = ExpSubject.Execute(&subject, check)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = ExpBody.Execute(&textBody, check)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = ExpHTML.Execute(&htmlBody, check)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return subject, textBody, textBody, htmlBody
|
||||
}
|
||||
Ссылка в новой задаче
Block a user