Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions fs/contube/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ func NewMemoryQueueFactory(ctx context.Context) TubeFactory {
func (f *MemoryQueueFactory) getOrCreateChan(name string) chan Record {
f.mu.Lock()
defer f.mu.Unlock()
defer func() {
if q, ok := f.queues[name]; ok {
slog.InfoContext(f.ctx, "Get memory queue chan",
"current_use_count", atomic.LoadInt32(&f.queues[name].refCnt),
"name", name)
}()
if q, ok := f.queues[name]; ok {
atomic.AddInt32(&q.refCnt, 1)
return q.c
}
c := make(chan Record, 100)
f.queues[name] = &queue{
c: c,
refCnt: 1,
}
slog.InfoContext(f.ctx, "Set memory queue chan",
"current_use_count", atomic.LoadInt32(&f.queues[name].refCnt),
"name", name)
return c
}

Expand Down Expand Up @@ -85,11 +85,6 @@ func (f *MemoryQueueFactory) NewSourceTube(ctx context.Context, configMap Config
for _, topic := range config.Topics {
t := topic
wg.Add(1)
go func() {
<-ctx.Done()
f.release(t)
}()

go func() {
defer wg.Done()
c := f.getOrCreateChan(t)
Expand Down