Documentation
¶
Overview ¶
Package id defines TypeID-based identity types for all Herald entities.
Every entity in Herald uses a single ID struct with a prefix that identifies the entity type. IDs are K-sortable (UUIDv7-based), globally unique, and URL-safe in the format "prefix_suffix".
Index ¶
- type DeviceID
- type ID
- func MustParse(s string) ID
- func New(prefix Prefix) ID
- func NewDeviceID() ID
- func NewInboxID() ID
- func NewMessageID() ID
- func NewPreferenceID() ID
- func NewProviderID() ID
- func NewScopedConfigID() ID
- func NewTemplateID() ID
- func NewTemplateVersionID() ID
- func Parse(s string) (ID, error)
- func ParseAny(s string) (ID, error)
- func ParseDeviceID(s string) (ID, error)
- func ParseInboxID(s string) (ID, error)
- func ParseMessageID(s string) (ID, error)
- func ParsePreferenceID(s string) (ID, error)
- func ParseProviderID(s string) (ID, error)
- func ParseScopedConfigID(s string) (ID, error)
- func ParseTemplateID(s string) (ID, error)
- func ParseTemplateVersionID(s string) (ID, error)
- func ParseWithPrefix(s string, expected Prefix) (ID, error)
- func (i ID) IsNil() bool
- func (i ID) MarshalBSONValue() (bsonType byte, data []byte, err error)
- func (i ID) MarshalText() ([]byte, error)
- func (i ID) Prefix() Prefix
- func (i *ID) Scan(src any) error
- func (i ID) String() string
- func (i *ID) UnmarshalBSONValue(t byte, data []byte) error
- func (i *ID) UnmarshalText(data []byte) error
- func (i ID) Value() (driver.Value, error)
- type InboxID
- type MessageID
- type PreferenceID
- type Prefix
- type ProviderID
- type ScopedConfigID
- type TemplateID
- type TemplateVersionID
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 Herald 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 New ¶
New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).
func NewPreferenceID ¶
func NewPreferenceID() ID
NewPreferenceID generates a new unique preference ID.
func NewScopedConfigID ¶
func NewScopedConfigID() ID
NewScopedConfigID generates a new unique scoped config ID.
func NewTemplateVersionID ¶
func NewTemplateVersionID() ID
NewTemplateVersionID generates a new unique template version ID.
func ParseDeviceID ¶
ParseDeviceID parses a string and validates the device prefix.
func ParseInboxID ¶
ParseInboxID parses a string and validates the inbox prefix.
func ParseMessageID ¶
ParseMessageID parses a string and validates the message prefix.
func ParsePreferenceID ¶
ParsePreferenceID parses a string and validates the preference prefix.
func ParseProviderID ¶
ParseProviderID parses a string and validates the provider prefix.
func ParseScopedConfigID ¶
ParseScopedConfigID parses a string and validates the scoped config prefix.
func ParseTemplateID ¶
ParseTemplateID parses a string and validates the template prefix.
func ParseTemplateVersionID ¶
ParseTemplateVersionID parses a string and validates the template version prefix.
func ParseWithPrefix ¶
ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.
func (ID) MarshalBSONValue ¶
MarshalBSONValue satisfies bson.ValueMarshaler (mongo-driver v2) so the ID is stored as a BSON string instead of an opaque struct.
func (ID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (ID) String ¶
String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.
func (*ID) UnmarshalBSONValue ¶
UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type PreferenceID ¶
type PreferenceID = ID
PreferenceID identifies a user's notification preferences.
type Prefix ¶
type Prefix string
Prefix identifies the entity type encoded in a TypeID.
const ( PrefixProvider Prefix = "hpvd" PrefixTemplate Prefix = "htpl" PrefixTemplateVersion Prefix = "htpv" PrefixMessage Prefix = "hmsg" PrefixInbox Prefix = "hinb" PrefixPreference Prefix = "hprf" PrefixScopedConfig Prefix = "hscf" PrefixDevice Prefix = "hdev" )
Prefix constants for all Herald entity types.
type ScopedConfigID ¶
type ScopedConfigID = ID
ScopedConfigID identifies a scoped provider configuration.
type TemplateVersionID ¶
type TemplateVersionID = ID
TemplateVersionID identifies a locale-specific template version.