Documentation
¶
Overview ¶
Package id defines TypeID-based identity types for all Chronicle entities.
Every entity in Chronicle 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 AnyID
- type ArchiveID
- type AuditID
- type CheckpointID
- type ErasureID
- type ID
- func MustParse(s string) ID
- func MustParseWithPrefix(s string, expected Prefix) ID
- func New(prefix Prefix) ID
- func NewArchiveID() ID
- func NewAuditID() ID
- func NewCheckpointID() ID
- func NewErasureID() ID
- func NewPluginID() ID
- func NewPolicyID() ID
- func NewReportID() ID
- func NewStreamID() ID
- func Parse(s string) (ID, error)
- func ParseAny(s string) (ID, error)
- func ParseArchiveID(s string) (ID, error)
- func ParseAuditID(s string) (ID, error)
- func ParseCheckpointID(s string) (ID, error)
- func ParseErasureID(s string) (ID, error)
- func ParsePluginID(s string) (ID, error)
- func ParsePolicyID(s string) (ID, error)
- func ParseReportID(s string) (ID, error)
- func ParseStreamID(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 PluginID
- type PolicyID
- type Prefix
- type ReportID
- type StreamID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchiveID ¶
type ArchiveID = ID
ArchiveID is a type-safe identifier for archives (prefix: "archive").
type AuditID ¶
type AuditID = ID
AuditID is a type-safe identifier for audit events (prefix: "audit").
type CheckpointID ¶
type CheckpointID = ID
CheckpointID is a type-safe identifier for checkpoints (prefix: "ckpt").
type ErasureID ¶
type ErasureID = ID
ErasureID is a type-safe identifier for erasure requests (prefix: "erasure").
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is the primary identifier type for all Chronicle 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 MustParseWithPrefix ¶
MustParseWithPrefix is like ParseWithPrefix but panics on error.
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 NewCheckpointID ¶
func NewCheckpointID() ID
NewCheckpointID generates a new unique checkpoint ID.
func Parse ¶
Parse parses a TypeID string (e.g., "audit_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.
func ParseArchiveID ¶
ParseArchiveID parses a string and validates the "archive" prefix.
func ParseAuditID ¶
ParseAuditID parses a string and validates the "audit" prefix.
func ParseCheckpointID ¶
ParseCheckpointID parses a string and validates the "ckpt" prefix.
func ParseErasureID ¶
ParseErasureID parses a string and validates the "erasure" prefix.
func ParsePluginID ¶
ParsePluginID parses a string and validates the "plugin" prefix.
func ParsePolicyID ¶
ParsePolicyID parses a string and validates the "retpol" prefix.
func ParseReportID ¶
ParseReportID parses a string and validates the "report" prefix.
func ParseStreamID ¶
ParseStreamID parses a string and validates the "stream" 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. No bson import needed because Go uses structural typing for interface satisfaction.
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 PluginID ¶
type PluginID = ID
PluginID is a type-safe identifier for plugins (prefix: "plugin").
type PolicyID ¶
type PolicyID = ID
PolicyID is a type-safe identifier for retention policies (prefix: "retpol").
type Prefix ¶
type Prefix string
Prefix identifies the entity type encoded in a TypeID.
const ( PrefixAudit Prefix = "audit" PrefixStream Prefix = "stream" PrefixErasure Prefix = "erasure" PrefixReport Prefix = "report" PrefixPolicy Prefix = "retpol" PrefixArchive Prefix = "archive" PrefixPlugin Prefix = "plugin" PrefixCheckpoint Prefix = "ckpt" )
Prefix constants for all Chronicle entity types.