id

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package id provides the primary identifier type for all ctrlplane entities. It wraps go.jetify.com/typeid to provide prefix-qualified, globally unique, sortable, URL-safe IDs in the format "prefix_suffix" (e.g., "inst_01h455vb4pex5vsknk084sn02q").

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

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

ID is the primary identifier type for all ctrlplane entities. It wraps a TypeID providing a prefix-qualified, globally unique, sortable, URL-safe identifier in the format "prefix_suffix".

var Nil ID

Nil is the zero-value ID.

func MustParse

func MustParse(s string) ID

MustParse is like Parse but panics on error. Use for hardcoded ID values.

func MustParseWithPrefix

func MustParseWithPrefix(s string, expected Prefix) ID

MustParseWithPrefix is like ParseWithPrefix but panics on error. Use for hardcoded ID values.

func New

func New(prefix Prefix) ID

New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).

func Parse

func Parse(s string) (ID, error)

Parse parses a TypeID string (e.g., "inst_01h455vb4pex5vsknk084sn02q") into an ID. Returns an error if the string is not valid.

func ParseWithPrefix

func ParseWithPrefix(s string, expected Prefix) (ID, error)

ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.

func (ID) IsNil

func (i ID) IsNil() bool

IsNil reports whether this ID is the zero value.

func (ID) MarshalText

func (i ID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ID) Prefix

func (i ID) Prefix() Prefix

Prefix returns the prefix component of this ID.

func (*ID) Scan

func (i *ID) Scan(src any) error

Scan implements sql.Scanner for database retrieval.

func (ID) String

func (i ID) String() string

String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ID) Value

func (i ID) Value() (driver.Value, error)

Value implements driver.Valuer for database storage. Returns nil for the Nil ID so that optional foreign key columns store NULL.

type Prefix

type Prefix string

Prefix identifies the entity type encoded in a TypeID.

const (
	PrefixInstance        Prefix = "inst"
	PrefixDeployment      Prefix = "dep"
	PrefixRelease         Prefix = "rel"
	PrefixHealthCheck     Prefix = "chk"
	PrefixHealthResult    Prefix = "hres"
	PrefixDomain          Prefix = "dom"
	PrefixRoute           Prefix = "rte"
	PrefixCertificate     Prefix = "cert"
	PrefixSecret          Prefix = "sec"
	PrefixWebhook         Prefix = "hook"
	PrefixWebhookDelivery Prefix = "deli"
	PrefixTenant          Prefix = "ten"
	PrefixAuditEntry      Prefix = "aud"
	PrefixEvent           Prefix = "evt"
)

Prefix constants for all ctrlplane entity types.

Jump to

Keyboard shortcuts

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