1package daemon23import (4 "context"5 "encoding/json"6 "github.com/FelineStateMachine/tinyrelay/internal/replication"7 "github.com/FelineStateMachine/tinyrelay/internal/work"8)910func (t *Tenant) guardWork(next work.Handler) work.Handler {11 return func(ctx context.Context, intent work.Intent) error {12 if intent.Kind == "job" {13 var spec replication.JobSpec14 if json.Unmarshal([]byte(intent.Payload), &spec) == nil && spec.Kind == replication.JobBackup {15 // The snapshot provider acquires exclusive admission itself.16 return next(ctx, intent)17 }18 }19 ctx, done, err := t.beginOperation(ctx)20 if err != nil {21 return err22 }23 defer done()24 return next(ctx, intent)25 }26}