datastore

package
v1.39.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 20 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.

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"
)
View Source
const MaxReplicaCount = 16

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(flagset *pflag.FlagSet, 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"`
	CredentialsProviderName     string        `debugmap:"visible"`
	FilterMaximumIDCount        uint16        `debugmap:"hidden" default:"100"`

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

	// Read Replicas
	ReadReplicaConnPool                ConnPoolConfig `debugmap:"visible"`
	ReadReplicaURIs                    []string       `debugmap:"sensitive"`
	ReadReplicaCredentialsProviderName string         `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"`
	SpannerCredentialsJSON []byte `debugmap:"sensitive"`
	SpannerEmulatorHost    string `debugmap:"visible"`
	SpannerMinSessions     uint64 `debugmap:"visible"`
	SpannerMaxSessions     uint64 `debugmap:"visible"`

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

	// Relationship Integrity
	RelationshipIntegrityEnabled     bool            `debugmap:"visible"`
	RelationshipIntegrityCurrentKey  RelIntegrityKey `debugmap:"visible"`
	RelationshipIntegrityExpiredKeys []string        `debugmap:"visible"`

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

	// Migrations
	MigrationPhase    string   `debugmap:"visible"`
	AllowedMigrations []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 SetAllowedMigrations added in v1.39.0

func SetAllowedMigrations(allowedMigrations []string) ConfigOption

SetAllowedMigrations returns an option that can set AllowedMigrations on a 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 SetReadReplicaURIs added in v1.35.0

func SetReadReplicaURIs(readReplicaURIs []string) ConfigOption

SetReadReplicaURIs returns an option that can set ReadReplicaURIs on a Config

func SetRelationshipIntegrityExpiredKeys added in v1.36.0

func SetRelationshipIntegrityExpiredKeys(relationshipIntegrityExpiredKeys []string) ConfigOption

SetRelationshipIntegrityExpiredKeys returns an option that can set RelationshipIntegrityExpiredKeys on a Config

func SetSpannerCredentialsJSON added in v1.34.0

func SetSpannerCredentialsJSON(spannerCredentialsJSON []byte) ConfigOption

SetSpannerCredentialsJSON returns an option that can set SpannerCredentialsJSON on a Config

func WithAllowedMigrations added in v1.39.0

func WithAllowedMigrations(allowedMigrations string) ConfigOption

WithAllowedMigrations returns an option that can append AllowedMigrationss to Config.AllowedMigrations

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 WithCredentialsProviderName added in v1.32.0

func WithCredentialsProviderName(credentialsProviderName string) ConfigOption

WithCredentialsProviderName returns an option that can set CredentialsProviderName 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 WithFilterMaximumIDCount added in v1.35.0

func WithFilterMaximumIDCount(filterMaximumIDCount uint16) ConfigOption

WithFilterMaximumIDCount returns an option that can set FilterMaximumIDCount 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 WithReadReplicaConnPool added in v1.35.0

func WithReadReplicaConnPool(readReplicaConnPool ConnPoolConfig) ConfigOption

WithReadReplicaConnPool returns an option that can set ReadReplicaConnPool on a Config

func WithReadReplicaCredentialsProviderName added in v1.35.0

func WithReadReplicaCredentialsProviderName(readReplicaCredentialsProviderName string) ConfigOption

WithReadReplicaCredentialsProviderName returns an option that can set ReadReplicaCredentialsProviderName on a Config

func WithReadReplicaURIs added in v1.35.0

func WithReadReplicaURIs(readReplicaURIs string) ConfigOption

WithReadReplicaURIs returns an option that can append ReadReplicaURIss to Config.ReadReplicaURIs

func WithRelationshipIntegrityCurrentKey added in v1.36.0

func WithRelationshipIntegrityCurrentKey(relationshipIntegrityCurrentKey RelIntegrityKey) ConfigOption

WithRelationshipIntegrityCurrentKey returns an option that can set RelationshipIntegrityCurrentKey on a Config

func WithRelationshipIntegrityEnabled added in v1.36.0

func WithRelationshipIntegrityEnabled(relationshipIntegrityEnabled bool) ConfigOption

WithRelationshipIntegrityEnabled returns an option that can set RelationshipIntegrityEnabled on a Config

func WithRelationshipIntegrityExpiredKeys added in v1.36.0

func WithRelationshipIntegrityExpiredKeys(relationshipIntegrityExpiredKeys string) ConfigOption

WithRelationshipIntegrityExpiredKeys returns an option that can append RelationshipIntegrityExpiredKeyss to Config.RelationshipIntegrityExpiredKeys

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 WithSpannerCredentialsJSON added in v1.34.0

func WithSpannerCredentialsJSON(spannerCredentialsJSON byte) ConfigOption

WithSpannerCredentialsJSON returns an option that can append SpannerCredentialsJSONs to Config.SpannerCredentialsJSON

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 WithWatchConnectTimeout added in v1.36.0

func WithWatchConnectTimeout(watchConnectTimeout time.Duration) ConfigOption

WithWatchConnectTimeout returns an option that can set WatchConnectTimeout 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

type RelIntegrityKey added in v1.36.0

type RelIntegrityKey struct {
	KeyID       string `debugmap:"visible"`
	KeyFilename string `debugmap:"visible"`
}

func NewRelIntegrityKeyWithOptions added in v1.36.0

func NewRelIntegrityKeyWithOptions(opts ...RelIntegrityKeyOption) *RelIntegrityKey

NewRelIntegrityKeyWithOptions creates a new RelIntegrityKey with the passed in options set

func NewRelIntegrityKeyWithOptionsAndDefaults added in v1.36.0

func NewRelIntegrityKeyWithOptionsAndDefaults(opts ...RelIntegrityKeyOption) *RelIntegrityKey

NewRelIntegrityKeyWithOptionsAndDefaults creates a new RelIntegrityKey with the passed in options set starting from the defaults

func RelIntegrityKeyWithOptions added in v1.36.0

func RelIntegrityKeyWithOptions(r *RelIntegrityKey, opts ...RelIntegrityKeyOption) *RelIntegrityKey

RelIntegrityKeyWithOptions configures an existing RelIntegrityKey with the passed in options set

func (RelIntegrityKey) DebugMap added in v1.36.0

func (r RelIntegrityKey) DebugMap() map[string]any

DebugMap returns a map form of RelIntegrityKey for debugging

func (*RelIntegrityKey) ToOption added in v1.36.0

func (r *RelIntegrityKey) ToOption() RelIntegrityKeyOption

ToOption returns a new RelIntegrityKeyOption that sets the values from the passed in RelIntegrityKey

func (*RelIntegrityKey) WithOptions added in v1.36.0

func (r *RelIntegrityKey) WithOptions(opts ...RelIntegrityKeyOption) *RelIntegrityKey

WithOptions configures the receiver RelIntegrityKey with the passed in options set

type RelIntegrityKeyOption added in v1.36.0

type RelIntegrityKeyOption func(r *RelIntegrityKey)

func WithKeyFilename added in v1.36.0

func WithKeyFilename(keyFilename string) RelIntegrityKeyOption

WithKeyFilename returns an option that can set KeyFilename on a RelIntegrityKey

func WithKeyID added in v1.36.0

func WithKeyID(keyID string) RelIntegrityKeyOption

WithKeyID returns an option that can set KeyID on a RelIntegrityKey

Jump to

Keyboard shortcuts

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