AddSubscriber adds a new subscriber to the transport.
(ctx context.Context, s *LocalSubscriber)
| 145 | |
| 146 | // AddSubscriber adds a new subscriber to the transport. |
| 147 | func (t *BoltTransport) AddSubscriber(ctx context.Context, s *LocalSubscriber) error { |
| 148 | select { |
| 149 | case <-t.closed: |
| 150 | return ErrClosedTransport |
| 151 | default: |
| 152 | } |
| 153 | |
| 154 | t.Lock() |
| 155 | t.subscribers.Add(s) |
| 156 | toSeq := t.lastSeq |
| 157 | t.Unlock() |
| 158 | |
| 159 | if s.RequestLastEventID != "" { |
| 160 | if err := t.dispatchHistory(ctx, s, toSeq); err != nil { |
| 161 | return err |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | s.Ready(ctx) |
| 166 | |
| 167 | return nil |
| 168 | } |
| 169 | |
| 170 | // RemoveSubscriber removes a new subscriber from the transport. |
| 171 | func (t *BoltTransport) RemoveSubscriber(_ context.Context, s *LocalSubscriber) error { |
nothing calls this directly
no test coverage detected