name

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package name holds the name rules shared by definitions and routing keys across the repository: queue jobs, schedule entries, broadcast topics and app events.

Identifier checks a single name and Routable checks a dot-separated routing key, optionally with wildcards. Both return plain errors; callers wrap them with their own ErrInvalidName sentinel.

if err := name.Identifier("send-receipt"); err != nil {
	return fmt.Errorf("invalid job name: %w", err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier

func Identifier(s string) error

Identifier validates s as a name of 1-64 bytes made of lowercase letters, digits, and hyphens that neither starts nor ends with a hyphen.

Example:

if err := name.Identifier("send-welcome-mail"); err != nil {
	return fmt.Errorf("invalid job name: %w", err)
}

func Routable

func Routable(s string, pattern bool) error

Routable validates s as a routing key: dot-separated tokens, each a valid Identifier, at most 255 bytes in total.

With pattern set, s is a receiver pattern: the token "*" may stand for any one token, and the token "#" may stand for the remaining tokens but only as the last token. Without pattern, wildcards are rejected.

Example:

if err := name.Routable("user.#", true); err != nil {
	return fmt.Errorf("invalid subscription: %w", err)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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