few mote usefull comments

This commit is contained in:
Krasi Georgiev 2018-01-12 13:58:23 +00:00
parent cabce21b70
commit 78ba5e62a6
1 changed files with 5 additions and 1 deletions

View File

@ -70,6 +70,8 @@ func NewManager(logger log.Logger) *Manager {
}
// Manager maintains a set of discovery providers and sends each update to a channel used by other packages.
// Targets are grouped by target set names.
// When a given target set doesn't include any targets the manager doesn't send any updates for this target set.
type Manager struct {
logger log.Logger
actionCh chan func(context.Context)
@ -160,7 +162,7 @@ func (m *Manager) updateGroup(poolKey poolKey, tgs []*targetgroup.Group) {
}
for _, tg := range tgs {
if tg != nil { // Some Discoverers send nil targetgroup so need to check for it to avoid panics.
if tg != nil { // Some Discoverers send nil target group so need to check for it to avoid panics.
if _, ok := m.targets[poolKey]; !ok {
m.targets[poolKey] = make(map[string]*targetgroup.Group)
}
@ -181,6 +183,8 @@ func (m *Manager) allGroups() map[string][]*targetgroup.Group {
for pkey, tsets := range m.targets {
del := true
for _, tg := range tsets {
// Don't add a target set if the target group has no targets.
// This happens when a Discoverer sends an empty targets array for a group to indicate that these targets have been removed.
if len(tg.Targets) != 0 {
tSetsAll[pkey.setName] = append(tSetsAll[pkey.setName], tg)
del = false