func (bwa *BatchedWriterAssembly) Close() {
	if bwa.writer != nil {
		bwa.assembly.SetWriter(bwa.writer)
		bwa.Batch.Close(bwa.assembly.Write, bwa.config.BatchFlushTimeout)
	} else {
		bwa.Batch.Close(bwa.assembly.Flush, bwa.config.BatchFlushTimeout)
	}
	bwa.writer.Close()
}
Close closes batch and writer
package components
import (
	"errors"
	"io"
	"time"
	"gollum/core"
	"github.com/sirupsen/logrus"
	"github.com/trivago/tgo/tmath"
)
type BatchedWriterConfig struct {
	BatchTimeout      time.Duration `config:"Batch/TimeoutSec" default:"5" metric:"sec"`
	BatchMaxCount     int           `config:"Batch/MaxCount" default:"8192"`
	BatchFlushCount   int           `config:"Batch/FlushCount" default:"4096"`
	BatchFlushTimeout time.Duration `config:"Batch/FlushTimeoutSec" default:"0" metric:"sec"`
}
func (c *BatchedWriterConfig) Configure(conf core.PluginConfigReader) {
	c.BatchFlushCount = tmath.MinI(c.BatchFlushCount, c.BatchMaxCount)
}
type BatchedWriterAssembly struct {
	Batch    core.MessageBatch  
	Created  time.Time          
	config   BatchedWriterConfig
	writer   BatchedWriter
	assembly core.WriterAssembly
	logger   logrus.FieldLogger
}
type BatchedWriter interface {
	io.WriteCloser
	Name() string  
	Size() int64   
	IsAccessible() bool
}
func NewBatchedWriterAssembly(config BatchedWriterConfig, modulator core.Modulator, tryFallback func(*core.Message), logger logrus.FieldLogger) *BatchedWriterAssembly {
	return &BatchedWriterAssembly{
		Batch:    core.NewMessageBatch(config.BatchMaxCount),
		assembly: core.NewWriterAssembly(nil, tryFallback, modulator),
		config:   config,
		logger:   logger,
	}
}
func (bwa *BatchedWriterAssembly) HasWriter() bool {
	return bwa.writer != nil
}
func (bwa *BatchedWriterAssembly) SetWriter(writer BatchedWriter) {
	bwa.writer = writer
	bwa.Created = time.Now()
}
func (bwa *BatchedWriterAssembly) UnsetWriter() {
	bwa.writer = nil
}
func (bwa *BatchedWriterAssembly) GetWriterAndUnset() BatchedWriter {
	writer := bwa.GetWriter()
	bwa.UnsetWriter()
	return writer
}
func (bwa *BatchedWriterAssembly) GetWriter() BatchedWriter {
	return bwa.writer
}
func (bwa *BatchedWriterAssembly) Flush() {
	if bwa.writer != nil {
		bwa.assembly.SetWriter(bwa.writer)
		bwa.Batch.Flush(bwa.assembly.Write)
	} else {
		bwa.Batch.Flush(bwa.assembly.Flush)
	}
}