Skip to content

Commit

Permalink
Switch to a config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
zix99 committed Jun 7, 2022
1 parent eba0ed8 commit da2aa88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/extractor/batchers/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
// ReadAheadBufferSize is the default size of the read-ahead buffer
const ReadAheadBufferSize = 128 * 1024

// AutoFlushTimeout sets time before an auto-flushing reader will write a batch
const AutoFlushTimeout = 250 * time.Millisecond

type Batcher struct {
c chan extractor.InputBatch

Expand Down
3 changes: 1 addition & 2 deletions pkg/extractor/batchers/readerBatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package batchers

import (
"io"
"time"
)

func OpenReaderToChan(sourceName string, reader io.ReadCloser, batchSize int) *Batcher {
Expand All @@ -12,7 +11,7 @@ func OpenReaderToChan(sourceName string, reader io.ReadCloser, batchSize int) *B
defer reader.Close()
defer out.close()
out.startFileReading(sourceName)
out.syncReaderToBatcherWithTimeFlush(sourceName, reader, batchSize, 250*time.Millisecond)
out.syncReaderToBatcherWithTimeFlush(sourceName, reader, batchSize, AutoFlushTimeout)
}()

return out
Expand Down
3 changes: 1 addition & 2 deletions pkg/extractor/batchers/tailBatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"rare/pkg/followreader"
"rare/pkg/logger"
"sync"
"time"
)

// TailFilesToChan tails a set of files to an input batcher that can be consumed by extractor
Expand All @@ -30,7 +29,7 @@ func TailFilesToChan(filenames <-chan string, batchSize int, reopen, poll bool)
return
}

out.syncReaderToBatcherWithTimeFlush(filename, r, batchSize, 250*time.Millisecond)
out.syncReaderToBatcherWithTimeFlush(filename, r, batchSize, AutoFlushTimeout)
}(filename)
}

Expand Down

0 comments on commit da2aa88

Please sign in to comment.