Skip to content

Commit 8f19ba5

Browse files
committed
avoid deleting outbound groups, just remove them from their parent
1 parent 831dcec commit 8f19ba5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

adapter/groups/manager.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ func (m *MutableGroupManager) Close() {
6565
m.removalQueue.close()
6666
}
6767

68-
func (m *MutableGroupManager) Groups() []adapter.MutableOutboundGroup {
68+
func (m *MutableGroupManager) OutboundGroup(tag string) (adapter.MutableOutboundGroup, bool) {
69+
group, found := m.groups[tag]
70+
return group, found
71+
}
72+
73+
func (m *MutableGroupManager) OutboundGroups() []adapter.MutableOutboundGroup {
6974
m.mu.Lock()
7075
defer m.mu.Unlock()
7176
return slices.Collect(maps.Values(m.groups))
@@ -151,8 +156,15 @@ func (m *MutableGroupManager) RemoveFromGroup(group, tag string) error {
151156
return fmt.Errorf("failed to remove %s from %s: %w", tag, group, err)
152157
}
153158

154-
_, isEndpoint := m.endpointMgr.Get(tag)
155-
m.removalQueue.enqueue(tag, isEndpoint)
159+
outbound, exists := m.outboundMgr.Outbound(tag)
160+
if !exists {
161+
return nil
162+
}
163+
// we don't want to delete outbound groups themselves
164+
if _, isOutboundGroup := outbound.(A.OutboundGroup); !isOutboundGroup {
165+
_, isEndpoint := m.endpointMgr.Get(tag)
166+
m.removalQueue.enqueue(tag, isEndpoint)
167+
}
156168
return nil
157169
}
158170

0 commit comments

Comments
 (0)