Split k.NewChatHandlerOBSOLETE
Some checks failed
rolling-release / build (push) Has been cancelled
rolling-release / rolling-release (push) Has been cancelled

This commit is contained in:
Dmitrii Okunev
2025-08-08 17:17:46 +01:00
parent c06d10bacc
commit 30db31ff36

View File

@@ -64,19 +64,24 @@ func NewChatHandlerOBSOLETE(
client: chatClient,
channelID: channelID,
cancelFunc: cancelFn,
messagesOutChan: make(chan streamcontrol.ChatMessage, 100),
onClose: onClose,
}
h.init(ctx)
return h, nil
}
func (h *ChatHandlerOBSOLETE) init(ctx context.Context) {
h.messagesOutChan = make(chan streamcontrol.ChatMessage, 100)
observability.Go(ctx, func(ctx context.Context) {
if onClose != nil {
defer func() {
onClose(ctx, h)
}()
if h.onClose != nil {
defer h.onClose(ctx, h)
}
defer func() {
close(h.messagesOutChan)
}()
defer close(h.messagesOutChan)
h.loop(ctx)
})
}
func (h *ChatHandlerOBSOLETE) loop(ctx context.Context) {
err := h.iterate(ctx)
if err != nil {
logger.Errorf(ctx, "unable to perform an iteration: %v", err)
@@ -97,9 +102,6 @@ func NewChatHandlerOBSOLETE(
return
}
}
})
return h, nil
}
func (h *ChatHandlerOBSOLETE) iterate(ctx context.Context) error {