func NewWriteToFileExecutor(filePath string, sql string, encoder utils.BinaryEncoder) *WriteToFileExecutor {
	absPath, err := filepath.Abs(filePath)
	if err != nil {
		ErrorExit("can't get absolute path for output file", err)
	}
	file, err := os.Create(absPath)
	if err != nil {
		ErrorExit("can't create output file", err)
	}
	writer := bufio.NewWriter(file)
	return &WriteToFileExecutor{sql: sql, file: file, writer: writer, encoder: encoder}
}
NewWriteToFileExecutor creates new object ready to write encoded sql to filePath
package main
import (
	"bufio"
	"container/list"
	"database/sql"
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"strings"
	"github.com/cossacklabs/acra/cmd"
	"github.com/cossacklabs/acra/decryptor/base"
	"github.com/cossacklabs/acra/keystore"
	"github.com/cossacklabs/acra/keystore/filesystem"
	keystoreV2 "github.com/cossacklabs/acra/keystore/v2/keystore"
	filesystemV2 "github.com/cossacklabs/acra/keystore/v2/keystore/filesystem"
	"github.com/cossacklabs/acra/logging"
	"github.com/cossacklabs/acra/utils"
	"github.com/cossacklabs/themis/gothemis/keys"
	_ "github.com/go-sql-driver/mysql"
	_ "github.com/lib/pq"
	log "github.com/sirupsen/logrus"
)
var (
	defaultConfigPath = utils.GetConfigPathByName("acra-rollback")
	serviceName       = "acra-rollback"
)
func ErrorExit(msg string, err error) {
	log.WithError(err).Errorln(msg)
	os.Exit(1)
}
type Executor interface {
	Execute([]byte)
	Close()
}
type InsertExecutor struct {
	insertStatement *sql.Stmt
}
func NewInsertExecutor(sql string, db *sql.DB) *InsertExecutor {
	stmt, err := db.Prepare(sql)
	if err != nil {
		ErrorExit("can't prepare sql statement", err)
	}
	return &InsertExecutor{insertStatement: stmt}
}
func (ex *InsertExecutor) Execute(data []byte) {
	_, err := ex.insertStatement.Exec(&data)
	if err != nil {
		ErrorExit("can't bind args to prepared statement", err)
	}
}
func (ex *InsertExecutor) Close() {
	ex.insertStatement.Close()
}
type WriteToFileExecutor struct {
	encoder utils.BinaryEncoder
	file    *os.File
	sql     string
	writer  *bufio.Writer
}