AddForward adds or updates a forward in the store
(snapshot ForwardSnapshot)
| 60 | |
| 61 | // AddForward adds or updates a forward in the store |
| 62 | func (s *Store) AddForward(snapshot ForwardSnapshot) { |
| 63 | s.mu.Lock() |
| 64 | defer s.mu.Unlock() |
| 65 | |
| 66 | // Check if this namespace is blocked (recently removed) |
| 67 | // This prevents race condition where port forward events arrive after namespace removal |
| 68 | nsKey := snapshot.Namespace + "." + snapshot.Context |
| 69 | if _, blocked := s.blockedNamespaces[nsKey]; blocked { |
| 70 | return // Silently ignore updates for blocked namespaces |
| 71 | } |
| 72 | |
| 73 | s.forwards[snapshot.Key] = &snapshot |
| 74 | |
| 75 | // Update or create service aggregate |
| 76 | if svc, ok := s.services[snapshot.ServiceKey]; ok { |
| 77 | s.updateServiceAggregate(svc) |
| 78 | } else { |
| 79 | s.services[snapshot.ServiceKey] = &ServiceSnapshot{ |
| 80 | Key: snapshot.ServiceKey, |
| 81 | ServiceName: snapshot.ServiceName, |
| 82 | Namespace: snapshot.Namespace, |
| 83 | Context: snapshot.Context, |
| 84 | Headless: snapshot.Headless, |
| 85 | } |
| 86 | s.updateServiceAggregate(s.services[snapshot.ServiceKey]) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // RemoveForward removes a forward from the store |
| 91 | func (s *Store) RemoveForward(key string) { |