mirror of https://github.com/milvus-io/milvus.git
Remove ctx from LongTermChecker (#7792)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/7808/head
parent
a9a01e1bc9
commit
85d73358cc
|
@ -354,6 +354,7 @@ func (s *Server) startDataNodeTtLoop(ctx context.Context) {
|
|||
if enableTtChecker {
|
||||
checker = NewLongTermChecker(ctx, ttCheckerName, ttMaxInterval, ttCheckerWarnMsg)
|
||||
checker.Start()
|
||||
defer checker.Stop()
|
||||
}
|
||||
for {
|
||||
select {
|
||||
|
|
|
@ -64,7 +64,7 @@ func VerifyResponse(response interface{}, err error) error {
|
|||
type LongTermChecker struct {
|
||||
d time.Duration
|
||||
t *time.Ticker
|
||||
ctx context.Context
|
||||
ch chan struct{}
|
||||
warn string
|
||||
name string
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ type LongTermChecker struct {
|
|||
func NewLongTermChecker(ctx context.Context, name string, d time.Duration, warn string) *LongTermChecker {
|
||||
c := &LongTermChecker{
|
||||
name: name,
|
||||
ctx: ctx,
|
||||
d: d,
|
||||
warn: warn,
|
||||
ch: make(chan struct{}),
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ func (c *LongTermChecker) Start() {
|
|||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
case <-c.ch:
|
||||
log.Warn(fmt.Sprintf("long term checker [%s] shutdown", c.name))
|
||||
return
|
||||
case <-c.t.C:
|
||||
|
@ -100,3 +100,9 @@ func (c *LongTermChecker) Start() {
|
|||
func (c *LongTermChecker) Check() {
|
||||
c.t.Reset(c.d)
|
||||
}
|
||||
|
||||
// Stop stop the checker
|
||||
func (c *LongTermChecker) Stop() {
|
||||
c.t.Stop()
|
||||
close(c.ch)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue