Skip to content

Commit

Permalink
nsq_to_file: don't open multiple GZIP streams
Browse files Browse the repository at this point in the history
This changes the structure of output files to be continuous GZIP
streams rather than concatenated GZIP streams.

This is likely slightly more compatible and expected.
  • Loading branch information
mreiferson committed Jan 4, 2019
1 parent 64c8c24 commit 5ea1012
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions apps/nsq_to_file/file_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,13 @@ func (f *FileLogger) Write(p []byte) (int, error) {
}

func (f *FileLogger) Sync() error {
var err error
if f.gzipWriter != nil {
f.gzipWriter.Close()
err = f.out.Sync()
f.gzipWriter, _ = gzip.NewWriterLevel(f, f.opts.GZIPLevel)
f.writer = f.gzipWriter
} else {
err = f.out.Sync()
err := f.gzipWriter.Flush()
if err != nil {
return err
}
}
return err
return f.out.Sync()
}

func (f *FileLogger) currentFilename() string {
Expand Down

0 comments on commit 5ea1012

Please sign in to comment.