feat: implement webhook notification system and integrate into queue manager
Build / Build and Push (push) Successful in 51s
Build / Build and Push (push) Successful in 51s
This commit is contained in:
@@ -14,18 +14,20 @@ type Manager struct {
|
||||
TriggerChan chan struct{}
|
||||
StopChan chan struct{}
|
||||
Broadcast func(string, interface{})
|
||||
WebhookURL string
|
||||
encoder *encoder.FFmpegManager
|
||||
isProcessing bool
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func NewManager(ffmpegPath, tempDir string, broadcast func(string, interface{})) *Manager {
|
||||
func NewManager(ffmpegPath, tempDir, webhookURL string, broadcast func(string, interface{})) *Manager {
|
||||
return &Manager{
|
||||
FFmpegPath: ffmpegPath,
|
||||
TempDir: tempDir,
|
||||
TriggerChan: make(chan struct{}, 1),
|
||||
StopChan: make(chan struct{}),
|
||||
Broadcast: broadcast,
|
||||
WebhookURL: webhookURL,
|
||||
encoder: encoder.NewManager(ffmpegPath),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"goencode/internal/db"
|
||||
"goencode/internal/encoder"
|
||||
"goencode/internal/notify"
|
||||
"io"
|
||||
)
|
||||
|
||||
@@ -98,6 +99,9 @@ func (m *Manager) processNextJob() {
|
||||
db.AddJobReport(job, "failed", 0, 0, 0)
|
||||
db.DeleteJob(job.ID)
|
||||
m.NotifySSE("job_failed", map[string]interface{}{"id": job.ID, "error": err.Error()})
|
||||
if m.WebhookURL != "" {
|
||||
notify.SendWebhook(m.WebhookURL, "Encoding Job Failed", fmt.Sprintf("File: %s\nError: %s", job.FilePath, err.Error()))
|
||||
}
|
||||
} else {
|
||||
log.Printf("Job %d succeeded", job.ID)
|
||||
db.DeleteJob(job.ID)
|
||||
|
||||
Reference in New Issue
Block a user