Documentation
¶
Overview ¶
Package contract holds the projection contract data types and their shape validation (ADR-103). It is a leaf — it imports only pkg/types and vocabulary — so the payload registry can hold a registered type's contracts without importing pkg/projection, which reaches graph, message, and natsclient. pkg/projection re-exports every name here as an alias, so a contract literal written against pkg/projection compiles unchanged.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidContract = errors.New("projection: invalid contract")
ErrInvalidContract identifies a projection contract rejected before use.
Functions ¶
func ValidateContracts ¶
ValidateContracts validates a complete, uniquely named contract set.
Types ¶
type Contract ¶
type Contract struct {
Name string `json:"name"`
MessageType semtypes.Type `json:"message_type"`
EntityPattern string `json:"entity_pattern"`
Groups []PredicateGroup `json:"groups,omitempty"`
BirthPredicates []string `json:"birth_predicates,omitempty"`
IndexingProfile string `json:"indexing_profile,omitempty"`
}
Contract declares the graph shape emitted by one projection. It validates caller intent; it does not reserve predicates or prevent other writers.
MessageType is the registered payload type the contract is bound to, carried structured (on the wire as {"domain","category","version"}, the same shape EntityState.message_type has) so nothing parses a key. A contract registered with a payload type inherits that type when the field is zero; a contract naming another type is a registration error.
func (Contract) Validate ¶
Validate checks one projection contract without consulting runtime state. Every predicate must be declared in the vocabulary.
func (Contract) ValidateShape ¶
ValidateShape checks everything Validate does except predicate declaration (name, entity pattern, groups, birth predicates, profile). The payload registry uses it so a contract can be registered before the vocabulary is populated; predicate declaration stays at mutation-client construction.
type PredicateGroup ¶
type PredicateGroup struct {
Name string `json:"name"`
Mode WriteMode `json:"mode"`
Predicates []string `json:"predicates"`
}
PredicateGroup names predicates changed together through one operation.