// Code generated by github.com/ecordell/optgen. DO NOT EDIT.
package datastore

import (
	defaults "github.com/creasty/defaults"
	helpers "github.com/ecordell/optgen/helpers"
	"time"
)

type ConnPoolConfigOption func(c *ConnPoolConfig)

// NewConnPoolConfigWithOptions creates a new ConnPoolConfig with the passed in options set
func NewConnPoolConfigWithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig {
	c := &ConnPoolConfig{}
	for _, o := range opts {
		o(c)
	}
	return c
}

// NewConnPoolConfigWithOptionsAndDefaults creates a new ConnPoolConfig with the passed in options set starting from the defaults
func NewConnPoolConfigWithOptionsAndDefaults(opts ...ConnPoolConfigOption) *ConnPoolConfig {
	c := &ConnPoolConfig{}
	defaults.MustSet(c)
	for _, o := range opts {
		o(c)
	}
	return c
}

// ToOption returns a new ConnPoolConfigOption that sets the values from the passed in ConnPoolConfig
func (c *ConnPoolConfig) ToOption() ConnPoolConfigOption {
	return func(to *ConnPoolConfig) {
		to.MaxIdleTime = c.MaxIdleTime
		to.MaxLifetime = c.MaxLifetime
		to.MaxLifetimeJitter = c.MaxLifetimeJitter
		to.MaxOpenConns = c.MaxOpenConns
		to.MinOpenConns = c.MinOpenConns
		to.HealthCheckInterval = c.HealthCheckInterval
	}
}

// DebugMap returns a map form of ConnPoolConfig for debugging
func (c ConnPoolConfig) DebugMap() map[string]any {
	debugMap := map[string]any{}
	debugMap["MaxIdleTime"] = helpers.DebugValue(c.MaxIdleTime, false)
	debugMap["MaxLifetime"] = helpers.DebugValue(c.MaxLifetime, false)
	debugMap["MaxLifetimeJitter"] = helpers.DebugValue(c.MaxLifetimeJitter, false)
	debugMap["MaxOpenConns"] = helpers.DebugValue(c.MaxOpenConns, false)
	debugMap["MinOpenConns"] = helpers.DebugValue(c.MinOpenConns, false)
	debugMap["HealthCheckInterval"] = helpers.DebugValue(c.HealthCheckInterval, false)
	return debugMap
}

// ConnPoolConfigWithOptions configures an existing ConnPoolConfig with the passed in options set
func ConnPoolConfigWithOptions(c *ConnPoolConfig, opts ...ConnPoolConfigOption) *ConnPoolConfig {
	for _, o := range opts {
		o(c)
	}
	return c
}

// WithOptions configures the receiver ConnPoolConfig with the passed in options set
func (c *ConnPoolConfig) WithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig {
	for _, o := range opts {
		o(c)
	}
	return c
}

// WithMaxIdleTime returns an option that can set MaxIdleTime on a ConnPoolConfig
func WithMaxIdleTime(maxIdleTime time.Duration) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.MaxIdleTime = maxIdleTime
	}
}

// WithMaxLifetime returns an option that can set MaxLifetime on a ConnPoolConfig
func WithMaxLifetime(maxLifetime time.Duration) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.MaxLifetime = maxLifetime
	}
}

// WithMaxLifetimeJitter returns an option that can set MaxLifetimeJitter on a ConnPoolConfig
func WithMaxLifetimeJitter(maxLifetimeJitter time.Duration) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.MaxLifetimeJitter = maxLifetimeJitter
	}
}

// WithMaxOpenConns returns an option that can set MaxOpenConns on a ConnPoolConfig
func WithMaxOpenConns(maxOpenConns int) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.MaxOpenConns = maxOpenConns
	}
}

// WithMinOpenConns returns an option that can set MinOpenConns on a ConnPoolConfig
func WithMinOpenConns(minOpenConns int) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.MinOpenConns = minOpenConns
	}
}

// WithHealthCheckInterval returns an option that can set HealthCheckInterval on a ConnPoolConfig
func WithHealthCheckInterval(healthCheckInterval time.Duration) ConnPoolConfigOption {
	return func(c *ConnPoolConfig) {
		c.HealthCheckInterval = healthCheckInterval
	}
}
