generator

package
v1.77.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("generator not found")

ErrNotFound for generator.

Module for fx.

Functions

This section is empty.

Types

type Application

type Application struct {
	Name      string `yaml:"name,omitempty" json:"name,omitempty" toml:"name,omitempty"`
	Kind      string `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
	Prefix    string `yaml:"prefix,omitempty" json:"prefix,omitempty" toml:"prefix,omitempty"`
	Suffix    string `yaml:"suffix,omitempty" json:"suffix,omitempty" toml:"suffix,omitempty"`
	Separator string `yaml:"separator,omitempty" json:"separator,omitempty" toml:"separator,omitempty"`
}

Application fto generate identifiers.

func (*Application) ID

func (a *Application) ID(id string) string

ID for the application.

type Config

type Config struct {
	Applications []*Application `yaml:"applications"`
}

Config for generator.

func (*Config) Application

func (c *Config) Application(name string) *Application

Application by name.

type Generator

type Generator interface {
	// Generate an identifier.
	Generate(ctx context.Context, app *Application) (string, error)
}

Generator to generate an identifier.

type Generators added in v1.10.0

type Generators map[string]Generator

Generators of identifiers.

func NewGenerators added in v1.10.0

func NewGenerators(db *mssqlx.DBs, client redis.Client) Generators

NewGenerators of identifiers.

func (Generators) Generator added in v1.10.0

func (gs Generators) Generator(kind string) (Generator, error)

Generator from kind.

type KSUID added in v1.3.0

type KSUID struct{}

KSUID generator.

func (*KSUID) Generate added in v1.3.0

func (k *KSUID) Generate(_ context.Context, app *Application) (string, error)

Generate a KSUID.

type NanoID added in v1.12.0

type NanoID struct{}

NanoID generator.

func (*NanoID) Generate added in v1.12.0

func (n *NanoID) Generate(_ context.Context, app *Application) (string, error)

Generate a NanoID.

type PG added in v1.5.0

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

PG generator.

func (*PG) Generate added in v1.5.0

func (p *PG) Generate(ctx context.Context, app *Application) (string, error)

Generate an ID using a sequence.

type Redis added in v1.6.0

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

Redis generator.

func (*Redis) Generate added in v1.6.0

func (r *Redis) Generate(ctx context.Context, app *Application) (string, error)

Generate an ID using INCR.

type Snowflake added in v1.7.0

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

Snowflake generator.

func NewSnowflake added in v1.9.1

func NewSnowflake() *Snowflake

NewSnowflake generator.

func (*Snowflake) Generate added in v1.7.0

func (s *Snowflake) Generate(_ context.Context, app *Application) (string, error)

Generate a id with snowflake.

type TypeID added in v1.21.0

type TypeID struct{}

TypeID generator.

func (*TypeID) Generate added in v1.21.0

func (t *TypeID) Generate(_ context.Context, app *Application) (string, error)

Generate a TypeID.

type ULID added in v1.4.0

type ULID struct{}

ULID generator.

func (*ULID) Generate added in v1.4.0

func (k *ULID) Generate(_ context.Context, app *Application) (string, error)

Generate a ULID.

type UUID

type UUID struct{}

UUID generator.

func (*UUID) Generate

func (g *UUID) Generate(_ context.Context, app *Application) (string, error)

Generate a UUID.

type XID added in v1.11.0

type XID struct{}

XID generator.

func (*XID) Generate added in v1.11.0

func (x *XID) Generate(_ context.Context, app *Application) (string, error)

Generate an XID.

Jump to

Keyboard shortcuts

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