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 3, 2019
1 parent 3616a7d commit deb7c33
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 @@ -211,16 +211,13 @@ func (f *FileLogger) Write(p []byte) (n int, err 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) calculateCurrentFilename() string {
Expand Down

0 comments on commit deb7c33

Please sign in to comment.