Documentation
¶
Overview ¶
Package id defines TypeID-based identity types for all Dispatch entities.
Every entity in Dispatch 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 ArtifactID
- type CheckpointID
- type CronID
- type DLQID
- type EventID
- type ID
- func MustParse(s string) ID
- func MustParseWithPrefix(s string, expected Prefix) ID
- func New(prefix Prefix) ID
- func NewArtifactID() ID
- func NewCheckpointID() ID
- func NewCronID() ID
- func NewDLQID() ID
- func NewEventID() ID
- func NewJobID() ID
- func NewRunID() ID
- func NewUsageID() ID
- func NewWorkerID() ID
- func NewWorkflowID() ID
- func Parse(s string) (ID, error)
- func ParseAny(s string) (ID, error)
- func ParseArtifactID(s string) (ID, error)
- func ParseCheckpointID(s string) (ID, error)
- func ParseCronID(s string) (ID, error)
- func ParseDLQID(s string) (ID, error)
- func ParseEventID(s string) (ID, error)
- func ParseJobID(s string) (ID, error)
- func ParseRunID(s string) (ID, error)
- func ParseUsageID(s string) (ID, error)
- func ParseWithPrefix(s string, expected Prefix) (ID, error)
- func ParseWorkerID(s string) (ID, error)
- func ParseWorkflowID(s string) (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) Time() time.Time
- func (i *ID) UnmarshalBSONValue(t byte, data []byte) error
- func (i *ID) UnmarshalText(data []byte) error
- func (i ID) Value() (driver.Value, error)
- type JobID
- type Prefix
- type RunID
- type UsageID
- type WorkerID
- type WorkflowID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactID ¶
type ArtifactID = ID
ArtifactID is a type-safe identifier for artifacts (prefix: "art").
type CheckpointID ¶
type CheckpointID = ID
CheckpointID is a type-safe identifier for workflow checkpoints (prefix: "ckpt").
type DLQID ¶
type DLQID = ID
DLQID is a type-safe identifier for dead letter queue entries (prefix: "dlq").
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is the primary identifier type for all Dispatch 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., "job_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.
func ParseArtifactID ¶
ParseArtifactID parses a string and validates the "art" prefix.
func ParseCheckpointID ¶
ParseCheckpointID parses a string and validates the "ckpt" prefix.
func ParseCronID ¶
ParseCronID parses a string and validates the "cron" prefix.
func ParseDLQID ¶
ParseDLQID parses a string and validates the "dlq" prefix.
func ParseEventID ¶
ParseEventID parses a string and validates the "evt" prefix.
func ParseJobID ¶
ParseJobID parses a string and validates the "job" prefix.
func ParseRunID ¶
ParseRunID parses a string and validates the "wfrun" prefix.
func ParseUsageID ¶
ParseUsageID parses a string and validates the "use" prefix.
func ParseWithPrefix ¶
ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.
func ParseWorkerID ¶
ParseWorkerID parses a string and validates the "wkr" prefix.
func ParseWorkflowID ¶
ParseWorkflowID parses a string and validates the "wf" prefix.
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) Time ¶
Time returns the creation instant carried in the ID's UUIDv7 timestamp, at millisecond precision. The nil ID returns the zero time.
Stores that keep IDs in an unordered structure (redis sets) use it to score an ordered index, which is why it lives here and not in a store.
func (*ID) UnmarshalBSONValue ¶
UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Prefix ¶
type Prefix string
Prefix identifies the entity type encoded in a TypeID.
const ( PrefixJob Prefix = "job" PrefixWorkflow Prefix = "wf" PrefixRun Prefix = "wfrun" PrefixCheckpoint Prefix = "ckpt" PrefixCron Prefix = "cron" PrefixDLQ Prefix = "dlq" PrefixEvent Prefix = "evt" PrefixWorker Prefix = "wkr" PrefixArtifact Prefix = "art" PrefixUsage Prefix = "use" )
Prefix constants for all Dispatch entity types.
type UsageID ¶
type UsageID = ID
UsageID is a type-safe identifier for usage records (prefix: "use").
type WorkflowID ¶
type WorkflowID = ID
WorkflowID is a type-safe identifier for workflow definitions (prefix: "wf").