🛠️ A simple, clean worker pool and task queue system designed for CLI apps.
Built in Go. Logs every task. Handles concurrency like a champ.
Install directly using go get:
go get github.com/brian-nunez/task-orchestration@latestImport it into your project:
import (
worker "github.com/brian-nunez/task-orchestration"
)Set up a worker pool and submit tasks:
pool := &worker.WorkerPool{
Concurreny: 4,
LogPath: "logs",
}
pool.Start()
defer pool.Stop()
pool.AddTask(&tasks.LoggerTask{
Text: "Doing some work",
LogLevel: "INFO",
Delay: time.Second,
})
pool.Wait()This will:
- Run tasks in parallel across 4 workers
- Write logs to individual .log files under the logs/ directory
Just implement the Task interface:
type Task interface {
Process(taskContext *worker.ProcessContext) error
}Here’s a simple example:
type PrintTask struct {
Message string
}
func (t *PrintTask) Process(ctx *worker.ProcessContext) error {
ctx.Logger("Processing task")
fmt.Println(t.Message)
return nil
}Each task creates a log file:
logs/{process-id}.logThese logs include:
- Worker ID
- Custom messages
- ✅ Plug-and-play with your Go CLI
- ✅ Per-task log files
- ✅ Easy to extend with your own tasks
See LICENSE file for details.
- brian-nunez - Maintainer