MCPcopy
hub / github.com/dunglas/mercure / AddSubscriber

Method AddSubscriber

bolt.go:147–168  ·  view source on GitHub ↗

AddSubscriber adds a new subscriber to the transport.

(ctx context.Context, s *LocalSubscriber)

Source from the content-addressed store, hash-verified

145
146// AddSubscriber adds a new subscriber to the transport.
147func (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.
171func (t *BoltTransport) RemoveSubscriber(_ context.Context, s *LocalSubscriber) error {

Callers

nothing calls this directly

Calls 3

dispatchHistoryMethod · 0.95
AddMethod · 0.80
ReadyMethod · 0.65

Tested by

no test coverage detected