tinyrelayfile
tinyrelay/internal/daemon/work_runtime.go/

internal/daemon/work_runtime.go raw
1package daemon
2
3import (
4 "context"
5
6 "github.com/FelineStateMachine/tinyrelay/internal/work"
7)
8
9// workRunner captures the tenant-wide queue composition before a worker
10// goroutine starts. Feature services contribute handlers; their jobs share
11// 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] = handler
16 }
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}
28
29// 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}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs