( ctx context.Context, chatID uuid.UUID, kind EventKind, runID uuid.UUID, stepID uuid.UUID, )
| 732 | } |
| 733 | |
| 734 | func (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 | } |
no test coverage detected