feat: publish standalone worker

Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
Gleb Tv
2026-07-13 17:55:14 +03:00
Коммит 2c7a0236da
309 изменённых файлов: 44004 добавлений и 0 удалений

53
spec/factories/notifications.go Обычный файл
Просмотреть файл

@@ -0,0 +1,53 @@
package factories
import (
"github.com/icrowley/fake"
"rsgit.ru/rsmon/rsmon/app/models"
)
// NotificationFactory provides functionality.
func NotificationFactory(account *models.Account, contactIDs, groupIDs []int64, alertDelay int64, notifyRestore bool) models.Notification {
BeforeExpiration := int64(3600)
notification := models.Notification{
Name: fake.Company(),
ContactIDs: contactIDs,
GroupIDs: groupIDs,
AlertDelay: &alertDelay,
NotifyDown: true,
NotifyRestore: notifyRestore,
BeforeExpiration: &BeforeExpiration,
}
if account == nil {
c := AccountFactory()
account = &c
}
notification.Account = account
notification.AccountID = account.ID
return notification
}
// PersistedNotification provides functionality.
func PersistedNotification(account *models.Account, contactIDs, groupIDs []int64, alertDelay int64, notifyRestore bool) models.Notification { //nolint:lll
notification := NotificationFactory(account, contactIDs, groupIDs, alertDelay, notifyRestore)
if notification.Account.ID == 0 {
err := models.DB().Save(&notification.Account).Error
if err != nil {
panic(err)
}
notification.AccountID = notification.Account.ID
}
err := models.DB().Save(&notification).Error
if err != nil {
panic(err)
}
err = notification.PersistRelations()
if err != nil {
panic(err)
}
return notification
}