Documentation
¶
Overview ¶
Package entity is the shared vocabulary of the Entity Lifecycle Pattern chassis: identifier types, the Command/Query contracts, and the read-only state views seen by both the defining and calling sides.
Index ¶
Constants ¶
const ( // DeleteSignalName marks an entity for deletion: drain, finalize, // complete. DeleteSignalName = "entity-delete" // DescribeQueryName answers DescribeOut at any time, even after the // workflow closed. DescribeQueryName = "describe" // SetLabelsCommandName is the built-in label-patch command every // entity serves: payload is map[string]string, empty values delete. SetLabelsCommandName = "entity-set-labels" // NoteSignalName carries a domain event into the entity's history — // a MILESTONE, not a log line: every note is a history event and // costs Continue-as-New budget. Streams belong in telemetry. NoteSignalName = "entity-note" )
Wire names of the entity protocol: the lifecycle signal and the describe query every entity serves. Exported so that OPERATORS — a control plane driving entities it did not define in Go — can address any entity generically; typed access still goes through entclient.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command[Res any] interface { Name() CommandName Result() Res }
Command is the contract of a tracked mutation (a Temporal Update): implemented by the user's request type.
type CommandInfo ¶
type CommandInfo struct {
Name CommandName
ReqType string
ResType string
}
CommandInfo describes a registered command for introspection — the seed of a future manifest (contracts enumerable from the same table that dispatches).
type DescribeOut ¶
type DescribeOut[Spec, State any] struct { Phase Phase `json:"phase"` Spec Spec `json:"spec"` State State `json:"state"` Labels map[string]string `json:"labels,omitempty"` PendingCommands int `json:"pendingCommands"` MarkedForDeletion bool `json:"markedForDeletion"` RunID string `json:"runId"` }
DescribeOut is the answer to the built-in "describe" query: current status plus pending work, queryable at any time without blocking.
type KindName ¶
type KindName string
KindName names an entity kind; it becomes the workflow type name and the workflow ID prefix.
type Phase ¶
type Phase string
Phase is the lifecycle phase of an entity, per the Entity Lifecycle Pattern: creation -> ready -> (deleting -> deleted | delete_failed).
type Query ¶
Query is the contract of a read-only projection: implemented by the user's request type.
type RequestID ¶
type RequestID string
RequestID is the application-level idempotency key of one command execution; the entity dedups it even across Continue-as-New.
func ParseRequestID ¶
ParseRequestID validates a request id from external input.
type ResourceID ¶
type ResourceID string
ResourceID identifies one resource within a kind. Workflow ID = "{kind}/{resource-id}".
func ParseResourceID ¶
func ParseResourceID(s string) (ResourceID, error)
ParseResourceID validates a resource id from external input.
func (ResourceID) Validate ¶
func (r ResourceID) Validate() error
Validate reports whether the resource id is well-formed.
type SelfValidator ¶
type SelfValidator interface {
Validate() error
}
SelfValidator is the optional method a command type may implement to reject requests before they reach Event History based on the request alone — the common case, and it needs no type parameters:
func (b BlueGreen) Validate() error { ... }
Must be pure and deterministic.
type Snapshot ¶
type Snapshot[Spec, State any] struct { Phase Phase Spec Spec State State Labels map[string]string PendingCommands int MarkedForDeletion bool }
Snapshot is a read-only, by-value view of the entity handed to query handlers and command validators. Both MUST be pure: a query or validator that mutates state is a replay-determinism bug, so they never see the live state — only this copy.