Add adds a service to the map, starting it on the supervisor. If there is already a service at the given key, it is removed first.
(k K, v S)
| 44 | // Add adds a service to the map, starting it on the supervisor. If there is |
| 45 | // already a service at the given key, it is removed first. |
| 46 | func (s *serviceMap[K, S]) Add(k K, v S) { |
| 47 | if tok, ok := s.tokens[k]; ok { |
| 48 | // There is already a service at this key, remove it first. |
| 49 | s.supervisor.Remove(tok) |
| 50 | } |
| 51 | s.services[k] = v |
| 52 | s.tokens[k] = s.supervisor.Add(v) |
| 53 | } |
| 54 | |
| 55 | // Get returns the service at the given key, or the empty value and false if |
| 56 | // there is no service at that key. |