store

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyses added in v0.0.2

type Analyses interface {
	AnalysesReader
	AnalysesWriter
}

Analyses exposes all queries in its generated store group.

type AnalysesReader added in v0.0.2

type AnalysesReader interface {
	// GetAnalysis executes the generated GetAnalysis query.
	GetAnalysis(ctx context.Context, arg *db.GetAnalysisParams, storeOptions ...QueryOption) (*db.Analysis, error)
}

AnalysesReader exposes read queries in the Analyses store group.

type AnalysesWriter added in v0.0.2

type AnalysesWriter interface {
}

AnalysesWriter exposes write queries in the Analyses store group.

type QueryOption added in v0.0.2

type QueryOption func(*queryOptions)

QueryOption customizes routing for one generated query call.

func ReadFromPrimary

func ReadFromPrimary() QueryOption

ReadFromPrimary routes a read query to the primary database.

func WithTx

func WithTx(tx pgx.Tx) QueryOption

WithTx executes a query through tx and suppresses write mirrors.

type ShardResolver

type ShardResolver[SK any] interface {
	// Tenant resolves the "tenant" shard route.
	Tenant(tenantID int64) SK
}

ShardResolver resolves generated query parameters to shard keys.

type ShardedOption added in v0.0.2

type ShardedOption func(*shardedOptions)

ShardedOption customizes a sharded topology.

func WithReplicaSet added in v0.0.2

func WithReplicaSet(name string, primary db.DBTX, replicas ...db.DBTX) ShardedOption

WithReplicaSet appends a named primary and its optional read replicas.

func WithVShardMapping added in v0.0.2

func WithVShardMapping(mainReplicaSet string, vshards []uint64, mirrorReplicaSets ...string) ShardedOption

WithVShardMapping maps virtual shards to a main replica set and optional ordered write mirrors.

type SingletonOption added in v0.0.2

type SingletonOption func(*singletonConfig)

SingletonOption customizes a single-database topology.

func WithDatabaseName added in v0.0.2

func WithDatabaseName(name string) SingletonOption

WithDatabaseName identifies the database in telemetry. An empty name defaults to "default".

func WithReadReplicas added in v0.0.2

func WithReadReplicas(databases ...db.DBTX) SingletonOption

WithReadReplicas appends databases used for round-robin reads.

func WithWriteMirrors added in v0.0.2

func WithWriteMirrors(databases ...db.DBTX) SingletonOption

WithWriteMirrors appends databases that synchronously receive writes.

type Store added in v0.0.2

type Store interface {
	// Analyses returns the Analyses query group.
	Analyses() Analyses
	// Users returns the Users query group.
	Users() Users
}

Store is the topology-independent generated query API.

func NewStore added in v0.0.2

func NewStore(ctx context.Context, topology Topology, options ...StoreOption) (Store, error)

NewStore creates the generated query API from an opaque topology configuration.

type StoreOption added in v0.0.2

type StoreOption func(*storeOptions)

StoreOption customizes telemetry for a generated store.

func WithLogger added in v0.0.2

func WithLogger(logger *slog.Logger) StoreOption

WithLogger configures optional structured logging for routed queries. A nil logger disables logging.

func WithMeterProvider added in v0.0.2

func WithMeterProvider(provider metric.MeterProvider) StoreOption

WithMeterProvider configures the provider used for routed query metrics. A nil provider uses the global OpenTelemetry meter provider.

func WithTracerProvider added in v0.0.2

func WithTracerProvider(provider trace.TracerProvider) StoreOption

WithTracerProvider configures the provider used for routed query spans. A nil provider uses the global OpenTelemetry tracer provider.

type Topology added in v0.0.2

type Topology interface {
	// contains filtered or unexported methods
}

Topology is an opaque database topology for Store.

func Sharded added in v0.0.2

func Sharded[SK any](numVShards uint64, shardHasher pgmesh.ShardHasher[SK], resolver ShardResolver[SK], options ...ShardedOption) Topology

Sharded returns an opaque sharded topology.

func Singleton added in v0.0.2

func Singleton(primary db.DBTX, options ...SingletonOption) Topology

Singleton returns a topology with one primary database.

type Users added in v0.0.2

type Users interface {
	UsersReader
	UsersWriter
}

Users exposes all queries in its generated store group.

type UsersReader added in v0.0.2

type UsersReader interface {
	// GetUser executes the generated GetUser query.
	GetUser(ctx context.Context, arg *db.GetUserParams, storeOptions ...QueryOption) (*db.User, error)
}

UsersReader exposes read queries in the Users store group.

type UsersWriter added in v0.0.2

type UsersWriter interface {
	// CreateUser executes the generated CreateUser query.
	CreateUser(ctx context.Context, arg *db.CreateUserParams, storeOptions ...QueryOption) (*db.User, error)
	// UpdateUserName executes the generated UpdateUserName query.
	UpdateUserName(ctx context.Context, arg *db.UpdateUserNameParams, storeOptions ...QueryOption) (*db.User, error)
}

UsersWriter exposes write queries in the Users store group.

Jump to

Keyboard shortcuts

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