diff --git a/pkg/alerting/alerting.go b/pkg/alerting/alerting.go index 769781b..a5ad0aa 100644 --- a/pkg/alerting/alerting.go +++ b/pkg/alerting/alerting.go @@ -138,7 +138,7 @@ func (as *alerter) HUP(cfg *config.Config) { // Go is the alerting loop. It does not start a goroutine. func (as *alerter) Go(ctx context.Context) { - ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "alerter"}) + ctx = entities.CtxWithServiceSubject(ctx, "alerter") err := as.startBackfill(ctx) if err != nil { diff --git a/pkg/database/partman/partman.go b/pkg/database/partman/partman.go index 391e284..9b7afcd 100644 --- a/pkg/database/partman/partman.go +++ b/pkg/database/partman/partman.go @@ -135,7 +135,7 @@ func New(db database.Store, cfg config.Partition) (*partman, error) { var _ PartitionManager = (*partman)(nil) func (pm *partman) Go(ctx context.Context) { - ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "partman"}) + ctx = entities.CtxWithServiceSubject(ctx, "partman") tick := time.NewTicker(CheckInterval) select { diff --git a/pkg/nexus/nexus.go b/pkg/nexus/nexus.go index 84d4020..766eaaf 100644 --- a/pkg/nexus/nexus.go +++ b/pkg/nexus/nexus.go @@ -39,7 +39,7 @@ func New() *Nexus { } func (n *Nexus) Go(ctx context.Context) { - ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "nexus"}) + ctx = entities.CtxWithServiceSubject(ctx, "nexus") for { select { case call, ok := <-n.callCh: diff --git a/pkg/rbac/entities/entities.go b/pkg/rbac/entities/entities.go index 293a9ca..62481a0 100644 --- a/pkg/rbac/entities/entities.go +++ b/pkg/rbac/entities/entities.go @@ -50,6 +50,10 @@ func CtxWithSubject(ctx context.Context, sub Subject) context.Context { return context.WithValue(ctx, SubjectCtxKey, sub) } +func CtxWithServiceSubject(ctx context.Context, name string) context.Context { + return CtxWithSubject(ctx, &SystemServiceSubject{Name: name}) +} + type subjectContextKey string const SubjectCtxKey subjectContextKey = "sub" diff --git a/pkg/shares/service.go b/pkg/shares/service.go index 245b61d..65f4dfa 100644 --- a/pkg/shares/service.go +++ b/pkg/shares/service.go @@ -23,7 +23,7 @@ type service struct { } func (s *service) Go(ctx context.Context) { - ctx = entities.CtxWithSubject(ctx, &entities.SystemServiceSubject{Name: "share"}) + ctx = entities.CtxWithServiceSubject(ctx, "share") tick := time.NewTicker(PruneInterval)