github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/ruler/lifecycle.go (about) 1 package ruler 2 3 import ( 4 "github.com/grafana/dskit/ring" 5 ) 6 7 func (r *Ruler) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, instanceID string, instanceDesc ring.InstanceDesc) (ring.InstanceState, ring.Tokens) { 8 // When we initialize the ruler instance in the ring we want to start from 9 // a clean situation, so whatever is the state we set it ACTIVE, while we keep existing 10 // tokens (if any). 11 var tokens []uint32 12 if instanceExists { 13 tokens = instanceDesc.GetTokens() 14 } 15 16 takenTokens := ringDesc.GetTokens() 17 newTokens := ring.GenerateTokens(r.cfg.Ring.NumTokens-len(tokens), takenTokens) 18 19 // Tokens sorting will be enforced by the parent caller. 20 tokens = append(tokens, newTokens...) 21 22 return ring.ACTIVE, tokens 23 } 24 25 func (r *Ruler) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens) {} 26 func (r *Ruler) OnRingInstanceStopping(_ *ring.BasicLifecycler) {} 27 func (r *Ruler) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc) { 28 }