func MaxRetries(maxRetries int) Option {
	return func(po *crdbOptions) {
		po.maxRetries = maxRetries
	}
}
MaxRetries is the maximum number of times a retriable transaction will be
client-side retried.
Default: 50
package crdb
import (
	"fmt"
	"time"
	"github.com/alecthomas/units"
	"github.com/authzed/spicedb/internal/datastore/common"
)
type crdbOptions struct {
	connMaxIdleTime *time.Duration
	connMaxLifetime *time.Duration
	minOpenConns    *int
	maxOpenConns    *int
	watchBufferLength           uint16
	revisionQuantization        time.Duration
	maxRevisionStalenessPercent float64
	gcWindow                    time.Duration
	maxRetries                  int
	splitAtEstimatedQuerySize   units.Base2Bytes
	overlapStrategy             string
	overlapKey                  string
}
const (
	errQuantizationTooLarge = "revision quantization (%s) must be less than GC window (%s)"
	overlapStrategyPrefix   = "prefix"
	overlapStrategyStatic   = "static"
	overlapStrategyInsecure = "insecure"
	defaultRevisionQuantization        = 5 * time.Second
	defaultMaxRevisionStalenessPercent = 0.1
	defaultWatchBufferLength           = 128
	defaultMaxRetries      = 50
	defaultOverlapKey      = "defaultsynckey"
	defaultOverlapStrategy = overlapStrategyStatic
)
type Option func(*crdbOptions)
func generateConfig(options []Option) (crdbOptions, error) {
	computed := crdbOptions{
		gcWindow:                    24 * time.Hour,
		watchBufferLength:           defaultWatchBufferLength,
		revisionQuantization:        defaultRevisionQuantization,
		maxRevisionStalenessPercent: defaultMaxRevisionStalenessPercent,
		splitAtEstimatedQuerySize:   common.DefaultSplitAtEstimatedQuerySize,
		maxRetries:                  defaultMaxRetries,
		overlapKey:                  defaultOverlapKey,
		overlapStrategy:             defaultOverlapStrategy,
	}
	for _, option := range options {
		option(&computed)
	}
	if computed.revisionQuantization >= computed.gcWindow {
		return computed, fmt.Errorf(
			errQuantizationTooLarge,
			computed.revisionQuantization,
			computed.gcWindow,
		)
	}
	return computed, nil
}
func SplitAtEstimatedQuerySize(splitAtEstimatedQuerySize units.Base2Bytes) Option {
	return func(po *crdbOptions) {
		po.splitAtEstimatedQuerySize = splitAtEstimatedQuerySize
	}
}
func ConnMaxIdleTime(idle time.Duration) Option {
	return func(po *crdbOptions) {
		po.connMaxIdleTime = &idle
	}
}
func ConnMaxLifetime(lifetime time.Duration) Option {
	return func(po *crdbOptions) {
		po.connMaxLifetime = &lifetime
	}
}
func MinOpenConns(conns int) Option {
	return func(po *crdbOptions) {
		po.minOpenConns = &conns
	}
}
func MaxOpenConns(conns int) Option {
	return func(po *crdbOptions) {
		po.maxOpenConns = &conns
	}
}
func WatchBufferLength(watchBufferLength uint16) Option {
	return func(po *crdbOptions) {
		po.watchBufferLength = watchBufferLength
	}
}
func RevisionQuantization(bucketSize time.Duration) Option {
	return func(po *crdbOptions) {
		po.revisionQuantization = bucketSize
	}
}
func MaxRevisionStalenessPercent(stalenessPercent float64) Option {
	return func(po *crdbOptions) {
		po.maxRevisionStalenessPercent = stalenessPercent
	}
}
func GCWindow(window time.Duration) Option {
	return func(po *crdbOptions) {
		po.gcWindow = window
	}
}