sequencer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sequencer provides SQLX-backed identifier allocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sequence

type Sequence struct {
	Value       int64
	IncrementBy int64
}

Sequence represents a sequence.

type Service

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

func New

func New(db *sql.DB, tx ...*sql.Tx) *Service

func (*Service) Allocate

func (s *Service) Allocate(ctx context.Context, table string, dest any, selector string) error

func (*Service) Reserve

func (s *Service) Reserve(ctx context.Context, table string, dest any, selector string) error

Reserve records supplied values before the first allocation for a table. It does not allocate, change the destination, or advance a database sequence. Callers with original-presence evidence pass only originally supplied rows. Native metadata unifies supplied-only aliases before allocation. A supplied transaction acquires native write intent before reading sequence identity.

func (*Service) WithStrategy

func (s *Service) WithStrategy(strategy dialect.PresetIDStrategy) *Service

WithStrategy explicitly selects a native strategy. Empty means the product default; Datly never substitutes a strategy based on transaction presence. Configure before the service is first used.

type Walker

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

func NewWalker

func NewWalker(value interface{}, selectors []string) (*Walker, error)

func (*Walker) Allocate

func (w *Walker) Allocate(value interface{}, seq *Sequence) error

Allocate allocate sequence.

func (*Walker) CountEmpty

func (w *Walker) CountEmpty(value interface{}) (int, error)

func (*Walker) EmptyLeaf

func (w *Walker) EmptyLeaf(value interface{}) (interface{}, error)

EmptyLeaf returns the first record whose leaf selector currently has a zero value.

func (*Walker) Leaf

func (w *Walker) Leaf(value interface{}) (interface{}, error)

Leaf returns a leaf value.

Jump to

Keyboard shortcuts

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