talaria icon indicating copy to clipboard operation
talaria copied to clipboard

When writter is nil, we should not ingest events

Open atlas-comstock opened this issue 2 years ago • 1 comments

// WriteBlock writes a one or multiple blocks to the underlying writer.
func (s *Flusher) WriteBlock(blocks []block.Block, schema typeof.Schema) error {
	if s.writer == nil || len(blocks) == 0 {
		return nil
	}

	// Merge the blocks based on the specified merging function
	// buffer, err := s.merge(blocks, schema)
	// if err != nil {
	//     return err
	// }

	// Generate the file name and write the data to the underlying writer
	return s.writer.Write(s.generateFileName(blocks[0]), blocks)
}

In Flusher, we should return an error when the writer is nil, otherwise, the badgerDB data will be deleted without writing to any writter. It would be better to keep them in badgerDB

atlas-comstock avatar Jun 17 '22 04:06 atlas-comstock

How about having a Writer scoped Flusher?

tardunge avatar Jun 17 '22 19:06 tardunge