orchard worker run: introduce "--synthetic" and "--workers" hidden flags (#390)

* orchard worker run: introduce "--synthetic" and "--workers" hidden flags

* Use slices.Clone() instead of directly assigning slices

* Use errgroup's context instead of command's context
This commit is contained in:
Nikolay Edigaryev
2026-01-28 16:50:25 +01:00
committed by GitHub
parent 7775515a73
commit a234ec8995
8 changed files with 106 additions and 31 deletions
+4 -9
View File
@@ -11,6 +11,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"github.com/cirruslabs/orchard/internal/config"
"github.com/cirruslabs/orchard/internal/controller"
@@ -142,21 +143,15 @@ func runDev(cmd *cobra.Command, args []string) error {
return devController.Run(ctx)
})
workerName, err := worker.DefaultName()
if err != nil {
return err
}
for i := range workers {
group.Go(func() error {
workerNameLocal := workerName
workerOptsLocal := slices.Clone(additionalWorkerOpts)
if workers > 1 {
workerNameLocal = fmt.Sprintf("%s-%d", workerName, i)
workerOptsLocal = append(workerOptsLocal, worker.WithNameSuffix(fmt.Sprintf("-%d", i+1)))
}
devWorker, err := CreateDevWorker(devClient, resources,
append(additionalWorkerOpts, worker.WithName(workerNameLocal)), logger)
devWorker, err := CreateDevWorker(devClient, resources, workerOptsLocal, logger)
if err != nil {
return err
}