datastore

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

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
	URI                         string
	GCWindow                    time.Duration
	LegacyFuzzing               time.Duration
	RevisionQuantization        time.Duration
	MaxRevisionStalenessPercent float64

	// Options
	ReadConnPool           ConnPoolConfig
	WriteConnPool          ConnPoolConfig
	SplitQueryCount        uint16
	ReadOnly               bool
	EnableDatastoreMetrics bool
	DisableStats           bool

	// Bootstrap
	BootstrapFiles        []string
	BootstrapFileContents map[string][]byte
	BootstrapOverwrite    bool
	BootstrapTimeout      time.Duration

	// Hedging
	RequestHedgingEnabled          bool
	RequestHedgingInitialSlowValue time.Duration
	RequestHedgingMaxRequests      uint64
	RequestHedgingQuantile         float64

	// CRDB
	FollowerReadDelay time.Duration
	MaxRetries        int
	OverlapKey        string
	OverlapStrategy   string

	// Postgres
	GCInterval         time.Duration
	GCMaxOperationTime time.Duration

	// Spanner
	SpannerCredentialsFile string
	SpannerEmulatorHost    string

	// MySQL
	TablePrefix string

	// Internal
	WatchBufferLength uint16

	// Migrations
	MigrationPhase string
}

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 (*Config) ToOption

func (c *Config) ToOption() ConfigOption

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

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 WithDisableStats added in v1.11.0

func WithDisableStats(disableStats bool) ConfigOption

WithDisableStats returns an option that can set DisableStats 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 WithSplitQueryCount

func WithSplitQueryCount(splitQueryCount uint16) ConfigOption

WithSplitQueryCount returns an option that can set SplitQueryCount 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 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
	MaxLifetime         time.Duration
	MaxLifetimeJitter   time.Duration
	MaxOpenConns        int
	MinOpenConns        int
	HealthCheckInterval time.Duration
}

func DefaultReadConnPool added in v1.18.0

func DefaultReadConnPool() *ConnPoolConfig

func DefaultWriteConnPool added in v1.18.0

func DefaultWriteConnPool() *ConnPoolConfig

Jump to

Keyboard shortcuts

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