func (config *Config) SetScriptOnPoison(script string) {
	config.scriptOnPoison = script
}
SetScriptOnPoison sets path to script to execute when poison record is triggered.
package common
import (
	"encoding/json"
	"errors"
	"io/ioutil"
	acracensor "github.com/cossacklabs/acra/acra-censor"
	"github.com/cossacklabs/acra/encryptor"
	encryptorConfig "github.com/cossacklabs/acra/encryptor/config"
	"github.com/cossacklabs/acra/keystore"
	"github.com/cossacklabs/acra/logging"
	"github.com/cossacklabs/acra/network"
	log "github.com/sirupsen/logrus"
	"go.opencensus.io/trace"
)
type Config struct {
	dbPort                  int
	dbHost                  string
	detectPoisonRecords     bool
	stopOnPoison            bool
	scriptOnPoison          string
	withZone                bool
	withAPI                 bool
	wholeMatch              bool
	acraConnectionString    string
	acraAPIConnectionString string
	ConnectionWrapper       network.ConnectionWrapper
	mysql                   bool
	postgresql              bool
	debug                   bool
	censor                  acracensor.AcraCensorInterface
	withConnector           bool
	TraceToLog              bool
	tableSchema             encryptorConfig.TableSchemaStore
	dataEncryptor           encryptor.DataEncryptor
	keystore                keystore.ServerKeyStore
	traceOptions            []trace.StartOption
	authDataPath            string
	serviceName             string
	configPath              string
}
type UIEditableConfig struct {
	DbHost           string `json:"db_host"`
	DbPort           int    `json:"db_port"`
	ConnectorAPIPort int    `json:"incoming_connection_api_port"`
	Debug            bool   `json:"debug"`
	ScriptOnPoison   string `json:"poison_run_script_file"`
	StopOnPoison     bool   `json:"poison_shutdown_enable"`
	WithZone         bool   `json:"zonemode_enable"`
}
func NewConfig() (*Config, error) {
	schemaStore, err := encryptorConfig.NewMapTableSchemaStore()
	if err != nil {
		return nil, err
	}
	traceOptions := []trace.StartOption{trace.WithSpanKind(trace.SpanKindServer), trace.WithSampler(trace.AlwaysSample())}
	return &Config{withZone: false, wholeMatch: true, mysql: false, postgresql: false, withConnector: true, tableSchema: schemaStore, traceOptions: traceOptions}, nil
}
var ErrTwoDBSetup = errors.New("only one db supported at one time")
func (config *Config) SetDBConnectionSettings(host string, port int) {
	config.dbHost = host
	config.dbPort = port
}
func (config *Config) WithConnector() bool {
	return config.withConnector
}
func (config *Config) SetWithConnector(v bool) {
	config.withConnector = v
}
func (config *Config) LoadMapTableSchemaConfig(path string) error {
	mapConfig, err := ioutil.ReadFile(path)
	if err != nil {
		log.WithField(logging.FieldKeyEventCode, logging.EventCodeErrorWrongConfiguration).WithError(err).Errorln("Can't read config for encryptor")
		return err
	}
	schema, err := encryptorConfig.MapTableSchemaStoreFromConfig(mapConfig)
	if err != nil {
		log.WithField(logging.FieldKeyEventCode, logging.EventCodeErrorWrongConfiguration).WithError(err).Errorln("Can't parse table schemas from config")
		return err
	}
	config.tableSchema = schema
	return nil
}
func (config *Config) GetTableSchema() encryptorConfig.TableSchemaStore {
	return config.tableSchema
}
func (config *Config) SetCensor(censorConfigPath string) error {
	censor := acracensor.NewAcraCensor()
	config.censor = censor
	if censorConfigPath == "" {
		return nil
	}
	configuration, err := ioutil.ReadFile(censorConfigPath)
	if err != nil {
		return err
	}
	err = censor.LoadConfiguration(configuration)
	if err != nil {
		return err
	}
	return nil
}
func (config *Config) GetCensor() acracensor.AcraCensorInterface {
	return config.censor
}
func (config *Config) UseMySQL() bool {
	return config.mysql
}
func (config *Config) UsePostgreSQL() bool {
	return config.postgresql
}
func (config *Config) SetDatabaseType(mysql, postgresql bool) error {
	if mysql && postgresql {
		return ErrTwoDBSetup
	}
	if !(mysql || postgresql) {
		postgresql = true
	}
	config.postgresql = postgresql
	config.mysql = mysql
	return nil
}
func (config *Config) SetAcraConnectionString(str string) {
	config.acraConnectionString = str
}
func (config *Config) SetAcraAPIConnectionString(str string) {
	config.acraAPIConnectionString = str
}
func (config *Config) SetDetectPoisonRecords(val bool) {
	config.detectPoisonRecords = val
}
func (config *Config) DetectPoisonRecords() bool {
	return config.detectPoisonRecords
}
func (config *Config) SetDebug(value bool) {
	config.debug = value
}
func (config *Config) GetDebug() bool {
	return config.debug
}
func (config *Config) GetWithZone() bool {
	return config.withZone
}
func (config *Config) SetWithZone(wz bool) {
	config.withZone = wz
}
func (config *Config) SetEnableHTTPAPI(api bool) {
	config.withAPI = api
}
func (config *Config) GetEnableHTTPAPI() bool {
	return config.withAPI
}
func (config *Config) GetDBHost() string {
	return config.dbHost
}
func (config *Config) GetDBPort() int {
	return config.dbPort
}
func (config *Config) GetWholeMatch() bool {
	return config.wholeMatch
}
func (config *Config) SetWholeMatch(value bool) {
	config.wholeMatch = value
}
func (config *Config) SetConfigPath(path string) {
	config.configPath = path
}
func (config *Config) GetConfigPath() string {
	return config.configPath
}
func (config *Config) ToJSON() ([]byte, error) {
	var s UIEditableConfig
	var err error
	s.DbHost = config.dbHost
	s.DbPort = config.dbPort
	_, s.ConnectorAPIPort, err = network.SplitConnectionString(config.acraAPIConnectionString)
	if err != nil {
		return nil, err
	}
	s.Debug = config.GetDebug()
	s.ScriptOnPoison = config.scriptOnPoison
	s.StopOnPoison = config.stopOnPoison
	s.WithZone = config.GetWithZone()
	out, err := json.Marshal(s)
	return out, err
}
func (config *Config) GetAcraConnectionString() string {
	return config.acraConnectionString
}
func (config *Config) GetAcraAPIConnectionString() string {
	return config.acraAPIConnectionString
}
func (config *Config) SetKeyStore(k keystore.ServerKeyStore) {
	config.keystore = k
}
func (config *Config) GetKeyStore() keystore.ServerKeyStore {
	return config.keystore
}
func (config *Config) GetTraceOptions() []trace.StartOption {
	return config.traceOptions
}
func (config *Config) SetAuthDataPath(path string) {
	config.authDataPath = path
}
func (config *Config) GetAuthDataPath() string {
	return config.authDataPath
}
func (config *Config) SetServiceName(name string) {
	config.serviceName = name
}
func (config *Config) GetServiceName() string {
	return config.serviceName
}