datastore

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Overview

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

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

Index

Constants

View Source
const (
	MemoryEngine    = "memory"
	PostgresEngine  = "postgres"
	CockroachEngine = "cockroachdb"
	SpannerEngine   = "spanner"
	MySQLEngine     = "mysql"
)

Variables

View Source
var BuilderForEngine = map[string]engineBuilderFunc{
	CockroachEngine: newCRDBDatastore,
	PostgresEngine:  newPostgresDatastore,
	MemoryEngine:    newMemoryDatstore,
	SpannerEngine:   newSpannerDatastore,
	MySQLEngine:     newMySQLDatastore,
}

Functions

func NewDatastore

func NewDatastore(ctx context.Context, options ...ConfigOption) (datastore.Datastore, error)

NewDatastore initializes a datastore given the options

func RegisterConnPoolFlagsWithPrefix added in v1.18.0

func RegisterConnPoolFlagsWithPrefix(flagSet *pflag.FlagSet, prefix string, defaults, opts *ConnPoolConfig)

func RegisterDatastoreFlags

func RegisterDatastoreFlags(cmd *cobra.Command, opts *Config) error

RegisterDatastoreFlags adds datastore flags to a cobra command.

func RegisterDatastoreFlagsWithPrefix added in v1.16.1

func RegisterDatastoreFlagsWithPrefix(flagSet *pflag.FlagSet, prefix string, opts *Config) error

RegisterDatastoreFlagsWithPrefix adds datastore flags to a cobra command, with each flag prefixed with the provided prefix argument. If left empty, the datastore flags are not prefixed.

Types

type Config

type Config struct {
	Engine                      string        `debugmap:"visible"`
	URI                         string        `debugmap:"sensitive"`
	GCWindow                    time.Duration `debugmap:"visible"`
	LegacyFuzzing               time.Duration `debugmap:"visible"`
	RevisionQuantization        time.Duration `debugmap:"visible"`
	MaxRevisionStalenessPercent float64       `debugmap:"visible"`

	// Options
	ReadConnPool           ConnPoolConfig `debugmap:"visible"`
	WriteConnPool          ConnPoolConfig `debugmap:"visible"`
	ReadOnly               bool           `debugmap:"visible"`
	EnableDatastoreMetrics bool           `debugmap:"visible"`
	DisableStats           bool           `debugmap:"visible"`

	// Bootstrap
	BootstrapFiles        []string          `debugmap:"visible-format"`
	BootstrapFileContents map[string][]byte `debugmap:"visible"`
	BootstrapOverwrite    bool              `debugmap:"visible"`
	BootstrapTimeout      time.Duration     `debugmap:"visible"`

	// Hedging
	RequestHedgingEnabled          bool          `debugmap:"visible"`
	RequestHedgingInitialSlowValue time.Duration `debugmap:"visible"`
	RequestHedgingMaxRequests      uint64        `debugmap:"visible"`
	RequestHedgingQuantile         float64       `debugmap:"visible"`

	// CRDB
	FollowerReadDelay         time.Duration `debugmap:"visible"`
	MaxRetries                int           `debugmap:"visible"`
	OverlapKey                string        `debugmap:"visible"`
	OverlapStrategy           string        `debugmap:"visible"`
	EnableConnectionBalancing bool          `debugmap:"visible"`
	ConnectRate               time.Duration `debugmap:"visible"`

	// Postgres
	GCInterval         time.Duration `debugmap:"visible"`
	GCMaxOperationTime time.Duration `debugmap:"visible"`

	// Spanner
	SpannerCredentialsFile string `debugmap:"visible"`
	SpannerEmulatorHost    string `debugmap:"visible"`
	SpannerMinSessions     uint64 `debugmap:"visible"`
	SpannerMaxSessions     uint64 `debugmap:"visible"`

	// MySQL
	TablePrefix string `debugmap:"visible"`

	// Internal
	WatchBufferLength       uint16        `debugmap:"visible"`
	WatchBufferWriteTimeout time.Duration `debugmap:"visible"`

	// Migrations
	MigrationPhase string `debugmap:"visible"`
}

func ConfigWithOptions

func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config

ConfigWithOptions configures an existing Config with the passed in options set

func DefaultDatastoreConfig

func DefaultDatastoreConfig() *Config

func NewConfigWithOptions

func NewConfigWithOptions(opts ...ConfigOption) *Config

NewConfigWithOptions creates a new Config with the passed in options set

func NewConfigWithOptionsAndDefaults added in v1.22.0

func NewConfigWithOptionsAndDefaults(opts ...ConfigOption) *Config

NewConfigWithOptionsAndDefaults creates a new Config with the passed in options set starting from the defaults

func (Config) DebugMap added in v1.22.0

func (c Config) DebugMap() map[string]any

DebugMap returns a map form of Config for debugging

func (*Config) ToOption

func (c *Config) ToOption() ConfigOption

ToOption returns a new ConfigOption that sets the values from the passed in Config

func (*Config) WithOptions added in v1.22.0

func (c *Config) WithOptions(opts ...ConfigOption) *Config

WithOptions configures the receiver Config with the passed in options set

type ConfigOption

type ConfigOption func(c *Config)

func SetBootstrapFileContents added in v1.16.2

func SetBootstrapFileContents(bootstrapFileContents map[string][]byte) ConfigOption

SetBootstrapFileContents returns an option that can set BootstrapFileContents on a Config

func SetBootstrapFiles

func SetBootstrapFiles(bootstrapFiles []string) ConfigOption

SetBootstrapFiles returns an option that can set BootstrapFiles on a Config

func WithBootstrapFileContents added in v1.16.2

func WithBootstrapFileContents(key string, value []byte) ConfigOption

WithBootstrapFileContents returns an option that can append BootstrapFileContentss to Config.BootstrapFileContents

func WithBootstrapFiles

func WithBootstrapFiles(bootstrapFiles string) ConfigOption

WithBootstrapFiles returns an option that can append BootstrapFiless to Config.BootstrapFiles

func WithBootstrapOverwrite

func WithBootstrapOverwrite(bootstrapOverwrite bool) ConfigOption

WithBootstrapOverwrite returns an option that can set BootstrapOverwrite on a Config

func WithBootstrapTimeout added in v1.15.0

func WithBootstrapTimeout(bootstrapTimeout time.Duration) ConfigOption

WithBootstrapTimeout returns an option that can set BootstrapTimeout on a Config

func WithConnectRate added in v1.22.0

func WithConnectRate(connectRate time.Duration) ConfigOption

WithConnectRate returns an option that can set ConnectRate on a Config

func WithDisableStats added in v1.11.0

func WithDisableStats(disableStats bool) ConfigOption

WithDisableStats returns an option that can set DisableStats on a Config

func WithEnableConnectionBalancing added in v1.22.0

func WithEnableConnectionBalancing(enableConnectionBalancing bool) ConfigOption

WithEnableConnectionBalancing returns an option that can set EnableConnectionBalancing on a Config

func WithEnableDatastoreMetrics added in v1.6.0

func WithEnableDatastoreMetrics(enableDatastoreMetrics bool) ConfigOption

WithEnableDatastoreMetrics returns an option that can set EnableDatastoreMetrics on a Config

func WithEngine

func WithEngine(engine string) ConfigOption

WithEngine returns an option that can set Engine on a Config

func WithFollowerReadDelay

func WithFollowerReadDelay(followerReadDelay time.Duration) ConfigOption

WithFollowerReadDelay returns an option that can set FollowerReadDelay on a Config

func WithGCInterval

func WithGCInterval(gCInterval time.Duration) ConfigOption

WithGCInterval returns an option that can set GCInterval on a Config

func WithGCMaxOperationTime

func WithGCMaxOperationTime(gCMaxOperationTime time.Duration) ConfigOption

WithGCMaxOperationTime returns an option that can set GCMaxOperationTime on a Config

func WithGCWindow

func WithGCWindow(gCWindow time.Duration) ConfigOption

WithGCWindow returns an option that can set GCWindow on a Config

func WithLegacyFuzzing added in v1.7.0

func WithLegacyFuzzing(legacyFuzzing time.Duration) ConfigOption

WithLegacyFuzzing returns an option that can set LegacyFuzzing on a Config

func WithMaxRetries

func WithMaxRetries(maxRetries int) ConfigOption

WithMaxRetries returns an option that can set MaxRetries on a Config

func WithMaxRevisionStalenessPercent added in v1.21.0

func WithMaxRevisionStalenessPercent(maxRevisionStalenessPercent float64) ConfigOption

WithMaxRevisionStalenessPercent returns an option that can set MaxRevisionStalenessPercent on a Config

func WithMigrationPhase added in v1.14.0

func WithMigrationPhase(migrationPhase string) ConfigOption

WithMigrationPhase returns an option that can set MigrationPhase on a Config

func WithOverlapKey

func WithOverlapKey(overlapKey string) ConfigOption

WithOverlapKey returns an option that can set OverlapKey on a Config

func WithOverlapStrategy

func WithOverlapStrategy(overlapStrategy string) ConfigOption

WithOverlapStrategy returns an option that can set OverlapStrategy on a Config

func WithReadConnPool added in v1.18.0

func WithReadConnPool(readConnPool ConnPoolConfig) ConfigOption

WithReadConnPool returns an option that can set ReadConnPool on a Config

func WithReadOnly

func WithReadOnly(readOnly bool) ConfigOption

WithReadOnly returns an option that can set ReadOnly on a Config

func WithRequestHedgingEnabled

func WithRequestHedgingEnabled(requestHedgingEnabled bool) ConfigOption

WithRequestHedgingEnabled returns an option that can set RequestHedgingEnabled on a Config

func WithRequestHedgingInitialSlowValue

func WithRequestHedgingInitialSlowValue(requestHedgingInitialSlowValue time.Duration) ConfigOption

WithRequestHedgingInitialSlowValue returns an option that can set RequestHedgingInitialSlowValue on a Config

func WithRequestHedgingMaxRequests

func WithRequestHedgingMaxRequests(requestHedgingMaxRequests uint64) ConfigOption

WithRequestHedgingMaxRequests returns an option that can set RequestHedgingMaxRequests on a Config

func WithRequestHedgingQuantile

func WithRequestHedgingQuantile(requestHedgingQuantile float64) ConfigOption

WithRequestHedgingQuantile returns an option that can set RequestHedgingQuantile on a Config

func WithRevisionQuantization

func WithRevisionQuantization(revisionQuantization time.Duration) ConfigOption

WithRevisionQuantization returns an option that can set RevisionQuantization on a Config

func WithSpannerCredentialsFile

func WithSpannerCredentialsFile(spannerCredentialsFile string) ConfigOption

WithSpannerCredentialsFile returns an option that can set SpannerCredentialsFile on a Config

func WithSpannerEmulatorHost added in v1.8.0

func WithSpannerEmulatorHost(spannerEmulatorHost string) ConfigOption

WithSpannerEmulatorHost returns an option that can set SpannerEmulatorHost on a Config

func WithSpannerMaxSessions added in v1.27.0

func WithSpannerMaxSessions(spannerMaxSessions uint64) ConfigOption

WithSpannerMaxSessions returns an option that can set SpannerMaxSessions on a Config

func WithSpannerMinSessions added in v1.27.0

func WithSpannerMinSessions(spannerMinSessions uint64) ConfigOption

WithSpannerMinSessions returns an option that can set SpannerMinSessions on a Config

func WithTablePrefix added in v1.7.0

func WithTablePrefix(tablePrefix string) ConfigOption

WithTablePrefix returns an option that can set TablePrefix on a Config

func WithURI

func WithURI(uRI string) ConfigOption

WithURI returns an option that can set URI on a Config

func WithWatchBufferLength added in v1.6.0

func WithWatchBufferLength(watchBufferLength uint16) ConfigOption

WithWatchBufferLength returns an option that can set WatchBufferLength on a Config

func WithWatchBufferWriteTimeout added in v1.29.0

func WithWatchBufferWriteTimeout(watchBufferWriteTimeout time.Duration) ConfigOption

WithWatchBufferWriteTimeout returns an option that can set WatchBufferWriteTimeout on a Config

func WithWriteConnPool added in v1.18.0

func WithWriteConnPool(writeConnPool ConnPoolConfig) ConfigOption

WithWriteConnPool returns an option that can set WriteConnPool on a Config

type ConnPoolConfig added in v1.18.0

type ConnPoolConfig struct {
	MaxIdleTime         time.Duration `debugmap:"visible"`
	MaxLifetime         time.Duration `debugmap:"visible"`
	MaxLifetimeJitter   time.Duration `debugmap:"visible"`
	MaxOpenConns        int           `debugmap:"visible"`
	MinOpenConns        int           `debugmap:"visible"`
	HealthCheckInterval time.Duration `debugmap:"visible"`
}

func ConnPoolConfigWithOptions added in v1.22.0

func ConnPoolConfigWithOptions(c *ConnPoolConfig, opts ...ConnPoolConfigOption) *ConnPoolConfig

ConnPoolConfigWithOptions configures an existing ConnPoolConfig with the passed in options set

func DefaultReadConnPool added in v1.18.0

func DefaultReadConnPool() *ConnPoolConfig

func DefaultWriteConnPool added in v1.18.0

func DefaultWriteConnPool() *ConnPoolConfig

func NewConnPoolConfigWithOptions added in v1.22.0

func NewConnPoolConfigWithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig

NewConnPoolConfigWithOptions creates a new ConnPoolConfig with the passed in options set

func NewConnPoolConfigWithOptionsAndDefaults added in v1.22.0

func NewConnPoolConfigWithOptionsAndDefaults(opts ...ConnPoolConfigOption) *ConnPoolConfig

NewConnPoolConfigWithOptionsAndDefaults creates a new ConnPoolConfig with the passed in options set starting from the defaults

func (ConnPoolConfig) DebugMap added in v1.22.0

func (c ConnPoolConfig) DebugMap() map[string]any

DebugMap returns a map form of ConnPoolConfig for debugging

func (*ConnPoolConfig) ToOption added in v1.22.0

func (c *ConnPoolConfig) ToOption() ConnPoolConfigOption

ToOption returns a new ConnPoolConfigOption that sets the values from the passed in ConnPoolConfig

func (*ConnPoolConfig) WithOptions added in v1.22.0

func (c *ConnPoolConfig) WithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig

WithOptions configures the receiver ConnPoolConfig with the passed in options set

type ConnPoolConfigOption added in v1.22.0

type ConnPoolConfigOption func(c *ConnPoolConfig)

func WithHealthCheckInterval added in v1.22.0

func WithHealthCheckInterval(healthCheckInterval time.Duration) ConnPoolConfigOption

WithHealthCheckInterval returns an option that can set HealthCheckInterval on a ConnPoolConfig

func WithMaxIdleTime

func WithMaxIdleTime(maxIdleTime time.Duration) ConnPoolConfigOption

WithMaxIdleTime returns an option that can set MaxIdleTime on a ConnPoolConfig

func WithMaxLifetime

func WithMaxLifetime(maxLifetime time.Duration) ConnPoolConfigOption

WithMaxLifetime returns an option that can set MaxLifetime on a ConnPoolConfig

func WithMaxLifetimeJitter added in v1.22.0

func WithMaxLifetimeJitter(maxLifetimeJitter time.Duration) ConnPoolConfigOption

WithMaxLifetimeJitter returns an option that can set MaxLifetimeJitter on a ConnPoolConfig

func WithMaxOpenConns

func WithMaxOpenConns(maxOpenConns int) ConnPoolConfigOption

WithMaxOpenConns returns an option that can set MaxOpenConns on a ConnPoolConfig

func WithMinOpenConns

func WithMinOpenConns(minOpenConns int) ConnPoolConfigOption

WithMinOpenConns returns an option that can set MinOpenConns on a ConnPoolConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL