Documentation
¶
Overview ¶
Package hook holds the hook event contract: the wire payload every domain publishes to its own hook topic for fire-and-forget lifecycle side effects.
Index ¶
- func Marshal(m proto.Message) ([]byte, error)
- func NewEventID(source, eventType, subjectID string, version int32) string
- func NewUnversionedEventID(source, eventType, subjectID, causeID string, ordinal int) string
- func TopicKeys(m proto.Message) []string
- func Unmarshal[T proto.Message](b []byte, m T) error
- func Validate(e *HookEvent) error
- type HookEvent
- type TopicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEventID ¶
NewEventID mints the id of an event describing a versioned state write.
Deriving the id rather than randomizing it is what makes replay safe: the same transition mints the same id, so the queue dedupes a redelivery and a hook stays idempotent without a publisher-side outbox. version is the subject's version immediately after the write, which is what separates two transitions of the same subject.
func NewUnversionedEventID ¶
NewUnversionedEventID mints the id of an event whose transition was not a versioned write, so no version distinguishes one occurrence from the next.
The causing message's id stands in for the version, being stable across redeliveries for the same reason a version is. ordinal separates several same-typed events published for one cause; pass 0 when there is only one.
func TopicKeys ¶
TopicKeys returns the logical topic keys bound to a message via the topic_keys proto option, or nil if it declares none. These are not wire topic names; a caller maps each key to its backend's topic.
func Validate ¶
Validate reports whether e carries the three envelope fields every consumer keys on. The rest cannot be checked generically: version is legitimately 0 for an unversioned transition and payload is shaped per type.
Both sides call it — a publisher to catch a malformed event before it reaches the queue, a consumer because the producer may not have.
Types ¶
type HookEvent ¶
HookEvent aliases the generated binding so callers reference the contract through this package rather than protopb.
type TopicKey ¶
TopicKey looks up a queue backend, topic name, and subscription config in a consumer.TopicRegistry.
const TopicKeyHook TopicKey = "hook"
TopicKeyHook carries hook events. The key is per-host, not global: each domain runs its own hook topic, so two domains sharing a queue backend must map this to distinct topic names.