Documentation
¶
Overview ¶
Package numbering hands out gapless numbers per (tenant, context, name), such as invoice numbers. Next runs in the transaction open in the context, so a rolled-back transaction gives its numbers back.
PgStore needs the identifier_sequences table from docs/postgres/schema.sql. InMemoryStore follows postgres.InMemoryUnitOfWork rollbacks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTenant is returned when the context carries no Tenant. ErrNoTenant = errors.New("numbering: no tenant in context") // ErrEmptySequence is returned when the context or name of a Sequence // is empty. ErrEmptySequence = errors.New("numbering: empty context or name") )
Functions ¶
This section is empty.
Types ¶
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore hands out numbers from memory. A rolled-back postgres.InMemoryUnitOfWork gives its numbers back. Unlike PgStore it does not make concurrent transactions wait, so if one rolls back after another has drawn a later number from the same sequence, a gap remains.
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore creates an empty InMemoryStore.
type PgOption ¶
type PgOption func(*PgStore)
PgOption configures a PgStore.
func WithSchema ¶
WithSchema sets the Postgres schema holding the identifier_sequences table. Defaults to public.
type PgStore ¶
type PgStore struct {
// contains filtered or unexported fields
}
PgStore hands out numbers from the identifier_sequences table.
func NewPgStore ¶
NewPgStore creates a PgStore that runs on the transaction in the context, or on pool outside one.