Service subject

This commit is contained in:
Daniel Ponte 2025-02-14 14:55:04 -05:00
parent ce5505de0b
commit e9d1da92a0
5 changed files with 8 additions and 4 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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:

View file

@ -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"

View file

@ -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)