Skip to content

Commit ebeab02

Browse files
committed
config: add ServiceConfig.WorkerRootPath() to guard documented layout
The <workspaces_root>/.workers derivation moved from a config.Parse default into example/main.go when ServiceConfig.WorkerRootPath was removed, but it was untested there (package main). Move it into config as a small method with its own test, so the layout documented on WorkspacesRoot can't drift silently again.
1 parent 5318a41 commit ebeab02

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

config/config_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ repository:
7070
}
7171
}
7272

73+
func TestServiceConfig_WorkerRootPath(t *testing.T) {
74+
// Guards the layout documented on ServiceConfig.WorkspacesRoot:
75+
// <workspaces_root>/.workers for worker checkouts.
76+
svc := ServiceConfig{WorkspacesRoot: "/tmp/x"}
77+
assert.Equal(t, filepath.Join("/tmp/x", ".workers"), svc.WorkerRootPath())
78+
}
79+
7380
func TestParse_ServiceDefaults(t *testing.T) {
7481
tests := []struct {
7582
name string

config/service_config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package config
1616

17+
import "path/filepath"
18+
1719
// ServiceConfig holds operational configuration for the Tango service.
1820
type ServiceConfig struct {
1921
// MaxWorkerPoolSize is the max number of concurrent requests per repository.
@@ -28,6 +30,12 @@ type ServiceConfig struct {
2830
Streaming ChunkConfig `yaml:"streaming"` // streaming chunk sizes; zero values fall back to package defaults
2931
}
3032

33+
// WorkerRootPath returns the root directory for worker workspace checkouts,
34+
// as documented on WorkspacesRoot: <workspaces_root>/.workers.
35+
func (s ServiceConfig) WorkerRootPath() string {
36+
return filepath.Join(s.WorkspacesRoot, ".workers")
37+
}
38+
3139
// ChunkConfig controls the number of entries per gRPC stream message.
3240
// All fields are optional; a zero value means "use the package default".
3341
// Tune these when a monorepo's per-target size causes messages to approach

example/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func run() error {
7272

7373
// Repo manager and orchestrator
7474
repoManagerClonePath := cfg.Service.WorkspacesRoot
75-
workerRootPath := filepath.Join(repoManagerClonePath, ".workers")
75+
workerRootPath := cfg.Service.WorkerRootPath()
7676
if err := os.MkdirAll(repoManagerClonePath, 0o755); err != nil {
7777
return fmt.Errorf("failed to create repo manager clone path: %w", err)
7878
}

0 commit comments

Comments
 (0)