MCPcopy Index your code
hub / github.com/coder/coder / publishChatStreamNotify

Method publishChatStreamNotify

coderd/x/chatd/chatd.go:5489–5507  ·  view source on GitHub ↗

publishChatStreamNotify broadcasts a per-chat stream notification via PostgreSQL pubsub so that all replicas can merge durable database updates with transient control events.

(chatID uuid.UUID, notify coderdpubsub.ChatStreamNotifyMessage)

Source from the content-addressed store, hash-verified

5487// PostgreSQL pubsub so that all replicas can merge durable database updates
5488// with transient control events.
5489func (p *Server) publishChatStreamNotify(chatID uuid.UUID, notify coderdpubsub.ChatStreamNotifyMessage) {
5490 if p.pubsub == nil {
5491 return
5492 }
5493 payload, err := json.Marshal(notify)
5494 if err != nil {
5495 p.logger.Error(context.Background(), "failed to marshal chat stream notify",
5496 slog.F("chat_id", chatID),
5497 slog.Error(err),
5498 )
5499 return
5500 }
5501 if err := p.pubsub.Publish(coderdpubsub.ChatStreamNotifyChannel(chatID), payload); err != nil {
5502 p.logger.Error(context.Background(), "failed to publish chat stream notify",
5503 slog.F("chat_id", chatID),
5504 slog.Error(err),
5505 )
5506 }
5507}
5508
5509// publishChatPubsubEvents broadcasts a lifecycle event for each affected chat.
5510func (p *Server) publishChatPubsubEvents(chats []database.Chat, kind codersdk.ChatWatchEventKind) {

Callers 15

SendMessageMethod · 0.95
EditMessageMethod · 0.95
DeleteQueuedMethod · 0.95
PromoteQueuedMethod · 0.95
publishStatusMethod · 0.95
publishRetryMethod · 0.95
publishErrorMethod · 0.95
publishMessageMethod · 0.95
publishEditedMessageMethod · 0.95
processChatMethod · 0.95

Calls 3

PublishMethod · 0.65
MarshalMethod · 0.45
ErrorMethod · 0.45