Add TCP Healthcheck
This commit is contained in:
parent
d1ab6ed489
commit
8392503df7
37 changed files with 2416 additions and 307 deletions
|
|
@ -266,19 +266,18 @@ func (m *Manager) getWRRServiceHandler(ctx context.Context, serviceName string,
|
|||
continue
|
||||
}
|
||||
|
||||
childName := service.Name
|
||||
updater, ok := serviceHandler.(healthcheck.StatusUpdater)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("child service %v of %v not a healthcheck.StatusUpdater (%T)", childName, serviceName, serviceHandler)
|
||||
return nil, fmt.Errorf("child service %v of %v not a healthcheck.StatusUpdater (%T)", service.Name, serviceName, serviceHandler)
|
||||
}
|
||||
|
||||
if err := updater.RegisterStatusUpdater(func(up bool) {
|
||||
balancer.SetStatus(ctx, childName, up)
|
||||
balancer.SetStatus(ctx, service.Name, up)
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("cannot register %v as updater for %v: %w", childName, serviceName, err)
|
||||
return nil, fmt.Errorf("cannot register %v as updater for %v: %w", service.Name, serviceName, err)
|
||||
}
|
||||
|
||||
log.Ctx(ctx).Debug().Str("parent", serviceName).Str("child", childName).
|
||||
log.Ctx(ctx).Debug().Str("parent", serviceName).Str("child", service.Name).
|
||||
Msg("Child service will update parent on status change")
|
||||
}
|
||||
|
||||
|
|
@ -342,19 +341,18 @@ func (m *Manager) getHRWServiceHandler(ctx context.Context, serviceName string,
|
|||
continue
|
||||
}
|
||||
|
||||
childName := service.Name
|
||||
updater, ok := serviceHandler.(healthcheck.StatusUpdater)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("child service %v of %v not a healthcheck.StatusUpdater (%T)", childName, serviceName, serviceHandler)
|
||||
return nil, fmt.Errorf("child service %v of %v not a healthcheck.StatusUpdater (%T)", service.Name, serviceName, serviceHandler)
|
||||
}
|
||||
|
||||
if err := updater.RegisterStatusUpdater(func(up bool) {
|
||||
balancer.SetStatus(ctx, childName, up)
|
||||
balancer.SetStatus(ctx, service.Name, up)
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("cannot register %v as updater for %v: %w", childName, serviceName, err)
|
||||
return nil, fmt.Errorf("cannot register %v as updater for %v: %w", service.Name, serviceName, err)
|
||||
}
|
||||
|
||||
log.Ctx(ctx).Debug().Str("parent", serviceName).Str("child", childName).
|
||||
log.Ctx(ctx).Debug().Str("parent", serviceName).Str("child", service.Name).
|
||||
Msg("Child service will update parent on status change")
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +464,7 @@ func (m *Manager) getLoadBalancerServiceHandler(ctx context.Context, serviceName
|
|||
|
||||
lb.AddServer(server.URL, proxy, server)
|
||||
|
||||
// servers are considered UP by default.
|
||||
// Servers are considered UP by default.
|
||||
info.UpdateServerStatus(target.String(), runtime.StatusUp)
|
||||
|
||||
healthCheckTargets[server.URL] = target
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue