Documentation
¶
Overview ¶
Package export defines the generated contract for entities that may leave the runtime. The source schema owns the contract; this package provides the small runtime needed to identify and filter an entity against it.
Index ¶
- Constants
- Variables
- func EnsureMarker(ctx context.Context, store entity.Store, id, marker entity.Id) (bool, error)
- type Attribute
- type BackfillOption
- type BackfillStats
- type Contract
- func (c *Contract) CanonicalJSON() ([]byte, error)
- func (c *Contract) Digest() string
- func (c *Contract) Filter(source *entity.Entity) (*entity.Entity, *Policy, error)
- func (c *Contract) MarkerID() entity.Id
- func (c *Contract) Policy(kind entity.Id) (*Policy, bool)
- func (c *Contract) PolicyFor(source entity.AttrGetter) (*Policy, bool)
- type Kind
- type Lifecycle
- type Policy
Constants ¶
const Version1 = 1
Variables ¶
var ErrKindNotExported = errors.New("entity kind is not exported")
Functions ¶
Types ¶
type Attribute ¶
type Attribute struct {
ID string `json:"id"`
Type string `json:"type"`
Parent string `json:"parent,omitempty"`
Many bool `json:"many,omitempty"`
EnumValues []string `json:"enum_values,omitempty"`
}
Attribute describes one allowed value. Parent is set for fields nested in a component. Ancestor component attributes are included automatically by the generator, so a validator can reconstruct the allowed tree without knowing the runtime's source schema.
type BackfillOption ¶
type BackfillOption func(*backfillConfig)
func ExcludingKinds ¶
func ExcludingKinds(kinds ...entity.Id) BackfillOption
ExcludingKinds leaves marker ownership for the named kinds to a more specialized migration. This is how deployment attempts stay unselectable until their canonical migration has validated each individual record.
type BackfillStats ¶
func BackfillMarker ¶
func BackfillMarker( ctx context.Context, log *slog.Logger, store entity.Store, contract *Contract, pageSize int64, options ...BackfillOption, ) (BackfillStats, error)
BackfillMarker makes existing entities selectable through the contract's one indexed marker. Generated encoders mark new writes; this pass is the additive upgrade path for records created by older runtimes.
type Contract ¶
type Contract struct {
Version int `json:"version"`
Target string `json:"target"`
Marker string `json:"marker"`
Kinds []Kind `json:"kinds"`
// contains filtered or unexported fields
}
Contract is the language-neutral description generated from schema.yml. Kinds and attributes are slices rather than maps so its JSON encoding is a stable, reviewable artifact and therefore a suitable digest input.
func (*Contract) CanonicalJSON ¶
CanonicalJSON returns the stable wire artifact. It deliberately ignores the compiled indexes and digest cached on Contract.