demo live stream

This commit is contained in:
2026-04-23 23:49:10 +01:00
parent bee7869af4
commit 285533c13e
9 changed files with 837 additions and 16 deletions

View File

@@ -154,13 +154,26 @@ func (ingest *Ingest) SubscribeLive(ctx context.Context, streamId string) (<-cha
if err != nil {
return nil, fmt.Errorf("failed to subscribe to live stream %s: %w", streamId, err)
}
defer active.pipeline.LiveUnsubscribe(id)
for {
select {
case <-ctx.Done():
return nil, nil
case buf := <-stream:
ingest.log.Debug("Received live stream chunk", "streamId", streamId, "chunkSize", buf.Len())
out := make(chan *bytes.Reader, 16)
go func() {
defer close(out)
defer active.pipeline.LiveUnsubscribe(id)
for {
select {
case <-ctx.Done():
return
case buf, ok := <-stream:
if !ok {
return
}
select {
case <-ctx.Done():
return
case out <- buf:
}
}
}
}
}()
return out, nil
}