1package daemon23import (4 "context"56 "github.com/FelineStateMachine/tinyrelay/internal/work"7)89// workRunner captures the tenant-wide queue composition before a worker10// goroutine starts. Feature services contribute handlers; their jobs share11// the same admission gate, observation and worker lifetime.12func (t *Tenant) workRunner() func(context.Context) error {13 handlers := t.replication.Handlers()14 for kind, handler := range t.workHandlers() {15 handlers[kind] = handler16 }17 for kind, handler := range handlers {18 handlers[kind] = t.guardWork(handler)19 }20 queue := t.replication.Queue()21 options := work.PoolOptions{22 Worker: work.WorkerOptions{Observe: t.app.telemetry.ObserveWork},23 }24 return func(ctx context.Context) error {25 return work.RunPool(ctx, queue, handlers, options)26 }27}2829// runWork composes a fresh runner for tests and explicit worker restarts.30func (t *Tenant) runWork(ctx context.Context) error {31 return t.workRunner()(ctx)32}