package mymysql

import (
	"gorm.io/gorm"
	"gorm.io/gorm/clause"
	"time"
)

type Opt func(m *MysqlDb)

func WithDisablePing(v bool) Opt {
	return func(m *MysqlDb) {
		m.disablePing = v
	}
}

func WithGormConfig(v *gorm.Config) Opt {
	return func(m *MysqlDb) {
		m.gormConfig = v
	}
}

func WithWriteJobNum(v int) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.jobNum = v
	}
}

func WithWriteChannelBuffer(v int) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.channelBuffer = v
	}
}

func WithWriteBatchSize(v int) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.batchSize = v
	}
}

func WithWriteIntervalTime(v time.Duration) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.batchInterval = v
	}
}

func WithAsyncWorkerNum(v int) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.asyncWorkerNum = v
	}
}

func WithClause(v ...clause.Expression) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.clauseExpr = v
	}
}

func WithDebug(v bool) BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.debug = v
	}
}

func WithNoPrepare() BatchWriterOpt {
	return func(c *BatchWriterConfig) {
		c.noPrepare = true
	}
}
