sequence

package
v1.0.0-beta.230 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GatheringInvoiceSequenceNumber = Definition{
		Prefix:         "GATHER",
		SuffixTemplate: "{{.CustomerPrefix}}-{{.Currency}}-{{.NextSequenceNumber}}",
		Scope:          "invoices/gathering",
		CommitMode:     CommitModeIndependent,
	}
	DraftInvoiceSequenceNumber = Definition{
		Prefix:         "DRAFT",
		SuffixTemplate: "{{.CustomerPrefix}}-{{.NextSequenceNumber}}",
		Scope:          "invoices/draft",

		CommitMode: CommitModeIndependent,
	}
)

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	entutils.TxCreator

	NextSequenceNumber(ctx context.Context, input NextSequenceNumberInput) (alpacadecimal.Decimal, error)
}

type CommitMode

type CommitMode string

CommitMode controls when a sequence allocation is committed. WithCaller allows the number to be reused if the caller rolls back; Independent retains the allocation despite caller rollback, which can create gaps.

const (
	CommitModeWithCaller  CommitMode = "with_caller"
	CommitModeIndependent CommitMode = "independent"
)

func (CommitMode) Validate

func (m CommitMode) Validate() error

type Definition

type Definition struct {
	Prefix         string
	SuffixTemplate string
	Scope          string
	CommitMode     CommitMode
}

func (Definition) PrefixMatches

func (d Definition) PrefixMatches(s string) bool

func (Definition) Validate

func (d Definition) Validate() error

type GenerationInput

type GenerationInput struct {
	Namespace    string
	CustomerName string
	Currency     currencyx.Code
}

func (GenerationInput) Validate

func (i GenerationInput) Validate() error

type NextSequenceNumberInput

type NextSequenceNumberInput struct {
	Namespace string
	Scope     string
}

func (NextSequenceNumberInput) Validate

func (n NextSequenceNumberInput) Validate() error

type Service

type Service interface {
	GenerateInvoiceSequenceNumber(ctx context.Context, in GenerationInput, def Definition) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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