collect submit source

This commit is contained in:
Robin Olsen
2026-03-24 12:32:57 +01:00
parent fc10321430
commit 6808ed3bbe
14 changed files with 300 additions and 63 deletions

View File

@@ -3,24 +3,30 @@ package task
import (
"context"
"time"
"github.com/LazyBachelor/LazyPM/internal/models"
)
type ValidationEngine struct {
task Tasker
}
func (v *ValidationEngine) Start(ctx context.Context, submitChan <-chan struct{}, onFeedback func(ValidationFeedback)) (done <-chan struct{}, stop chan<- struct{}) {
func (v *ValidationEngine) Start(ctx context.Context, submitChan <-chan models.ValidationTrigger, onFeedback func(ValidationFeedback, models.ValidationTriggerSource)) (done <-chan struct{}, stop chan<- struct{}) {
doneChan := make(chan struct{}, 1)
stopChan := make(chan struct{}, 1)
go func() {
for {
select {
case <-submitChan:
case trigger := <-submitChan:
feedback := v.task.Validate(ctx)
source := trigger.Source
if source == "" {
source = models.ValidationTriggerUnknown
}
if onFeedback != nil {
onFeedback(feedback)
onFeedback(feedback, source)
}
if feedback.Success {