sqlrelay

package module
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sqlrelay contains the standard-library SQL implementation shared by durable SQL providers. Database drivers remain application dependencies.

Index

Constants

This section is empty.

Variables

View Source
var ErrSequenceRange = errors.New("crdt SQL durable provider: sequence exceeds signed bigint range")

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxEvents uint64
	MaxBytes  uint64
	Timeout   time.Duration
}

Config bounds one retained operation log per group. Timeout applies to each Append and Replay call because durable.Log intentionally has no context parameter; connection and pool lifetime remain application-owned.

type Dialect

type Dialect struct {
	Name             string
	MaxGroupIDBytes  int
	MaxActorIDBytes  int
	MaxEnvelopeBytes uint64
	// ValidateGroupID and ValidateActorID provide a provider-specific final
	// identifier check after the common non-empty and byte-limit guards. They
	// are useful for stores whose indexed text keys have a second constraint,
	// such as a UTF-16 code-unit limit. Nil keeps the common checks only.
	ValidateGroupID func(string) bool
	ValidateActorID func(string) bool
	Schema          []string
	AppendOptions   sql.TxOptions
	ReplayOptions   sql.TxOptions
	InsertGroup     string
	LockGroup       string
	ReadDot         string
	InsertEvent     string
	InsertDot       string
	UpdateGroup     string
	ReadHighWater   string
	ReadEvents      string
}

Dialect supplies fixed, audited SQL for one database family. All statements must use database/sql placeholders and must preserve the durable.Log transaction contract documented by the owning provider package.

type Store

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

Store implements durable.Log with a provider-specific transaction dialect. It does not close the supplied *sql.DB, which may be shared by handlers.

func New

func New(database *sql.DB, config Config, dialect Dialect) (*Store, error)

New validates provider limits around an application-owned database/sql pool. It does not import or register a database driver.

func (*Store) Append

func (store *Store) Append(groupID string, change replica.Change) (durable.AppendResult, error)

Append atomically binds a dot to its canonical envelope, reserves the next group-local sequence, and updates capacity metadata.

func (*Store) Close

func (store *Store) Close() error

Close marks Store unavailable. It deliberately does not close the pool.

func (*Store) Closed

func (store *Store) Closed() bool

Closed implements durable.Log.

func (*Store) EnsureSchema

func (store *Store) EnsureSchema(ctx context.Context) error

EnsureSchema creates fixed provider tables. It is intentionally explicit so applications can use a migration role instead of granting runtime DDL.

func (*Store) Replay

func (store *Store) Replay(groupID string, after, maxEvents, maxBytes uint64, manifest replica.Manifest, policy crdt.ProtocolPolicy, maxMessageBytes, maxActorBytes int) (events []durable.Event, highWater uint64, resultErr error)

Replay reads one provider snapshot and refuses a partial, corrupt, over-budget, or manifest-incompatible suffix.

Jump to

Keyboard shortcuts

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