store

package
v0.6.37 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package store stands in for an infra package (pkg/backplane/infra/postgres, infra/valkey): a config section plus a deps.Provider built from it. The service embeds the section in its Config and passes it to New explicitly.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrScheme is returned for a DSN the store cannot open.
	ErrScheme = errors.New("store: only mem:// is supported")
	// ErrDown is what the probe reports while Config.Down is set.
	ErrDown = errors.New("store: down")
)

Errors.

Functions

func New

func New(cfg *Config) deps.Provider[*DB]

New is the provider of a store configured by cfg.

Types

type Config

type Config struct {
	// Connection string; never printed.
	DSN config.Secret `json:"dsn" schemapb:"default=mem://"`
	// Requests slower than this are logged; changed live from the console.
	SlowLog config.Live[time.Duration] `json:"slow_log" schemapb:"default=100ms"`
	// Makes the probe fail, as an outage would: a required store takes the
	// instance out of readiness, an optional one (ProbeOptional) disappears
	// from Get. Changed live from the console.
	Down config.Live[bool] `json:"down" schemapb:"default=false"`
}

Config of one store.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB counts greetings per name.

func (*DB) Inc

func (db *DB) Inc(ctx context.Context, name string) uint64

Inc counts a greeting for name and returns the new count.

func (*DB) Total

func (db *DB) Total() uint64

Total greetings.

Jump to

Keyboard shortcuts

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