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

Method publishEvent

coderd/x/chatd/chatdebug/service.go:734–775  ·  view source on GitHub ↗
(
	ctx context.Context,
	chatID uuid.UUID,
	kind EventKind,
	runID uuid.UUID,
	stepID uuid.UUID,
)

Source from the content-addressed store, hash-verified

732}
733
734func (s *Service) publishEvent(
735 ctx context.Context,
736 chatID uuid.UUID,
737 kind EventKind,
738 runID uuid.UUID,
739 stepID uuid.UUID,
740) {
741 if s.pubsub == nil {
742 s.log.Debug(ctx,
743 "chat debug pubsub unavailable; skipping event",
744 slog.F("kind", kind),
745 slog.F("chat_id", chatID),
746 )
747 return
748 }
749
750 event := DebugEvent{
751 Kind: kind,
752 ChatID: chatID,
753 RunID: runID,
754 StepID: stepID,
755 }
756 data, err := json.Marshal(event)
757 if err != nil {
758 s.log.Warn(ctx, "failed to marshal chat debug event",
759 slog.Error(err),
760 slog.F("kind", kind),
761 slog.F("chat_id", chatID),
762 )
763 return
764 }
765
766 channel := PubsubChannel(chatID)
767 if err := s.pubsub.Publish(channel, data); err != nil {
768 s.log.Warn(ctx, "failed to publish chat debug event",
769 slog.Error(err),
770 slog.F("channel", channel),
771 slog.F("kind", kind),
772 slog.F("chat_id", chatID),
773 )
774 }
775}

Callers 7

CreateRunMethod · 0.95
UpdateRunMethod · 0.95
CreateStepMethod · 0.95
UpdateStepMethod · 0.95
DeleteByChatIDMethod · 0.95
DeleteAfterMessageIDMethod · 0.95
FinalizeStaleMethod · 0.95

Calls 4

PubsubChannelFunction · 0.85
PublishMethod · 0.65
MarshalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected