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

Method shutdown

subscribe.go:373–390  ·  view source on GitHub ↗
(ctx context.Context, s *LocalSubscriber)

Source from the content-addressed store, hash-verified

371}
372
373func (h *Hub) shutdown(ctx context.Context, s *LocalSubscriber) {
374 // Notify that the client is closing the connection
375 s.Disconnect()
376
377 ctx = context.WithoutCancel(ctx)
378
379 if err := h.transport.RemoveSubscriber(ctx, s); err != nil && h.logger.Enabled(ctx, slog.LevelError) {
380 h.logger.LogAttrs(ctx, slog.LevelError, "Failed to remove subscriber on shutdown", slog.Any("error", err))
381 }
382
383 h.dispatchSubscriptionUpdate(ctx, s, false)
384
385 if h.logger.Enabled(ctx, slog.LevelInfo) {
386 h.logger.LogAttrs(ctx, slog.LevelInfo, "Subscriber disconnected")
387 }
388
389 h.metrics.SubscriberDisconnected(s)
390}
391
392func (h *Hub) dispatchSubscriptionUpdate(ctx context.Context, s *LocalSubscriber, active bool) {
393 if !h.subscriptions {

Callers 1

SubscribeHandlerMethod · 0.95

Calls 5

DisconnectMethod · 0.80
EnabledMethod · 0.80
RemoveSubscriberMethod · 0.65

Tested by

no test coverage detected