Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlstore

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sqlstore implements lease.Store with database/sql.

Index

Constants

View Source
const (
	DriverPostgres = "postgres"
	DriverMySQL    = "mysql"
	DriverSQLite   = "sqlite"

	MigrateAuto = "auto"
	MigrateOff  = "off"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver  string
	DSN     string
	Migrate string
}

Config configures a SQL Store.

type Store

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

Store persists lease records in a SQL database.

func New

func New(ctx context.Context, cfg Config) (*Store, error)

New opens a SQL-backed lease store and applies the schema when configured.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database handle.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key lease.Key) (*lease.Record, error)

Get implements lease.Store.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]lease.Record, error)

List implements lease.Store.

func (*Store) Ping added in v0.2.0

func (s *Store) Ping(ctx context.Context) error

Ping implements lease.Store. It verifies a live database connection without touching the leases table, so a readiness probe stays constant-cost.

func (*Store) Put

func (s *Store) Put(ctx context.Context, expectedVersion int64, rec *lease.Record) error

Put implements lease.Store. The version predicate lives in the SQL itself: the insert is create-if-absent and the update matches WHERE version = ? and stores version + 1, so rows-affected tells the whole CAS story.

Jump to

Keyboard shortcuts

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