Provide task queue registration and service container injection.

This commit is contained in:
mikestefanello 2024-06-19 13:53:44 -04:00
parent 0d2ad6e936
commit 912ae2ca6b
5 changed files with 96 additions and 78 deletions

View file

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"log"
"log/slog"
"net/http"
"os"
"os/signal"
@ -57,15 +56,10 @@ func main() {
}
}()
q := services.NewQueue[tasks.ExampleTask](
func(ctx context.Context, task tasks.ExampleTask) error {
slog.Info("Example task received", "message", task.Message)
return nil
},
)
c.Tasks.Register(q)
// Register all task queues
tasks.Register(c)
// Start the scheduler service to queue periodic tasks
// Start the task runner to executed queued tasks
ctx, cancel := context.WithCancel(context.Background())
c.Tasks.StartRunner(ctx)