sequencer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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