nomadcode/services/core/internal/notification/service.go
toki d121f8f094 feat: mattermost task notification adapter and agent-task archive
- Add mattermost notification sink adapter
- Update notification service and scheduler tests
- Archive completed agent-task files for 04+01,02,03_adapter_boundary
- Rename plan/review files to archive format
2026-06-03 20:02:37 +09:00

44 lines
949 B
Go

package notification
import (
"context"
"errors"
"log/slog"
)
type Service struct {
logger *slog.Logger
sinks []TaskEventSink
}
func NewService(logger *slog.Logger, sinks ...TaskEventSink) *Service {
return &Service{
logger: logger,
sinks: append([]TaskEventSink{}, sinks...),
}
}
func (s *Service) NotifyTaskCompleted(ctx context.Context, input TaskNotification) error {
return s.NotifyTaskEvent(ctx, TaskEvent{
Type: TaskEventCompleted,
TaskID: input.TaskID,
Title: input.Title,
Status: input.Status,
Message: input.Message,
})
}
func (s *Service) NotifyTaskEvent(ctx context.Context, input TaskEvent) error {
if s.logger != nil {
s.logger.Info("task event notification requested", "type", input.Type, "task_id", input.TaskID)
}
var errs []error
for _, sink := range s.sinks {
if err := sink.HandleTaskEvent(ctx, input); err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}