Service subject
This commit is contained in:
parent
ce5505de0b
commit
e9d1da92a0
5 changed files with 8 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue