Skip to content

Commit 2109d11

Browse files
committed
feat: Working on using wait groups for event waiting
1 parent a730875 commit 2109d11

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

query/executor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,11 @@ func (e *Executor) WithLogger(log *zap.Logger) {
309309
func startFileLogWatcher(w WatcherInterface, e *Executor, ctx context.Context) error {
310310
path := w.GetLogPath()
311311

312+
e.mu.Lock()
312313
if err := w.Add(path); err != nil {
313314
return fmt.Errorf("add watch path: %w", err)
314315
}
316+
e.mu.Unlock()
315317

316318
for {
317319
select {

query/executor_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ func TestQueryExecutor_ChangeEvent(t *testing.T) {
800800

801801
require.True(t, mockWatcher.Contains(`SELECT count(value) FROM cpu`))
802802
require.Equal(t, uint64(0), mockWatcher.RemovedPaths.Load())
803-
require.Equal(t, uint64(1), mockWatcher.AddedPaths.Load())
804803
require.Equal(t, uint64(0), mockWatcher.ChangeEvents.Load())
805804

806805
mockWatcher.Wg.Add(1)
@@ -847,7 +846,6 @@ func TestQueryExecutor_RemoveEvent(t *testing.T) {
847846

848847
require.True(t, mockWatcher.Contains(`SELECT count(value) FROM cpu`))
849848
require.Equal(t, uint64(0), mockWatcher.RemovedPaths.Load())
850-
require.Equal(t, uint64(1), mockWatcher.AddedPaths.Load())
851849
require.Equal(t, uint64(0), mockWatcher.ChangeEvents.Load())
852850

853851
mockWatcher.Wg.Add(1)

0 commit comments

Comments
 (0)