Skip to content

Commit

Permalink
feat: Working on using wait groups for event waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed Jan 8, 2025
1 parent a730875 commit 2109d11
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 2 additions & 0 deletions query/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,11 @@ func (e *Executor) WithLogger(log *zap.Logger) {
func startFileLogWatcher(w WatcherInterface, e *Executor, ctx context.Context) error {
path := w.GetLogPath()

e.mu.Lock()
if err := w.Add(path); err != nil {
return fmt.Errorf("add watch path: %w", err)
}
e.mu.Unlock()

for {
select {
Expand Down
2 changes: 0 additions & 2 deletions query/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ func TestQueryExecutor_ChangeEvent(t *testing.T) {

require.True(t, mockWatcher.Contains(`SELECT count(value) FROM cpu`))
require.Equal(t, uint64(0), mockWatcher.RemovedPaths.Load())
require.Equal(t, uint64(1), mockWatcher.AddedPaths.Load())
require.Equal(t, uint64(0), mockWatcher.ChangeEvents.Load())

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

require.True(t, mockWatcher.Contains(`SELECT count(value) FROM cpu`))
require.Equal(t, uint64(0), mockWatcher.RemovedPaths.Load())
require.Equal(t, uint64(1), mockWatcher.AddedPaths.Load())
require.Equal(t, uint64(0), mockWatcher.ChangeEvents.Load())

mockWatcher.Wg.Add(1)
Expand Down

0 comments on commit 2109d11

Please sign in to comment.