hof

package
v0.6.9-alpha.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

notes

once we start pushing this package out to more of the code base we might want to consider using a hof/runtime to house the common pieces across the major features, loading and enriching the CUE as a whole, then being able to work with any of the sub-features

For now, we are only using this setup in datamodel as a POC. Gen should be easy to update after that, flow with the rewrite

Documentation

Overview

This package manages the #hof: _ configuration and the various @<hof>() attributes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(v cue.Value, before func(cue.Value) bool, after func(cue.Value), options ...cue.Option)

Walk is an alternative to cue.Value.Walk which handles more field types You can customize this with your own options returning false will stop recursion for that node

func WalkOrig added in v0.6.9

func WalkOrig(v cue.Value, before func(cue.Value) bool, after func(cue.Value), options ...cue.Option)

Walk is an alternative to cue.Value.Walk which handles more field types You can customize this with your own options returning false will stop recursion for that node

Types

type Chat

type Chat struct {
	Root  bool
	Name  string
	Extra string
}

hof/chat configuration

type Datamodel

type Datamodel struct {
	// Root for datamodel features
	// This acts as the entrypoint
	// the other fields determine behavior
	Root bool

	// index, pivot, level, hierachy, node?
	Node bool

	// Enable snapshots and history in .hof/dm/...
	History bool

	// create an Ordered<Label> list in parent data
	// where elements are from CUE iteration of fields
	Ordered bool

	// treat as a cue value
	// nesting stops here and the whole
	// value is tracked as a singular value
	// support incomplete values & schemas
	Cue bool

	// Semantic version for value
	Version string
}

hof/datamodel configuration

type Flow

type Flow struct {
	Root bool
	Name string
	Task string

	// middleware related
	Pool  Pool
	Print Print
}
  hof/flow configuration
  this has more shorthands
	@flow() | @flow(name)
	@task(op) | @task(op,name)

type Gen

type Gen struct {
	Root    bool
	Name    string
	Creator bool
}

hof/gen configuration #hof: gen: "name" @gen(name)

type Hof

type Hof struct {
	// label from containing value in CUE
	Label string

	// path to containing value in CUE
	Path string

	// Semantic hof datamodel api-version for compat
	APIVersion string

	// #hof: metadata: ...
	Metadata Metadata

	// #hof: <feature>: ...
	// @<feature>(<name>) can be shorthand with no-name implying label?
	Datamodel Datamodel
	Gen       Gen
	Flow      Flow
	Chat      Chat

	// any extra config, set by users
	Extra map[string]any
}

#hof: ...

type Metadata

type Metadata struct {
	// A unique ID as @id(string) generated by hof
	ID string `json:"id"`

	// Given name for the value
	Name string

	// arbitrary key=string data
	Labels map[string]string

	// CUE import path / package
	// only needs to be set if importing elsewhere
	Package string
}

Common Metadata

type Node

type Node[T any] struct {
	Hof Hof

	// do not modify, root value containing
	Value cue.Value

	// The wrapping type
	T *T

	// heirarchy of tracked values
	Parent *Node[T]
	// we (this node) are in between
	Children []*Node[T]
}

func FindHofs

func FindHofs(value cue.Value) (roots []*Node[any], err error)

func FindHofsOrig added in v0.6.9

func FindHofsOrig(value cue.Value) (roots []*Node[any], err error)

func New

func New[T any](label string, val cue.Value, curr *T, parent *Node[T]) *Node[T]

func ParseHof added in v0.6.9

func ParseHof[T any](val cue.Value) (*Node[T], error)

parse out a #hof for a single value

func Upgrade

func Upgrade[S, T any](src *Node[S], upgrade func(*Node[T]) *T, parent *Node[T]) *Node[T]

func (*Node[T]) Print

func (hn *Node[T]) Print()

func (*Node[T]) PrintDatamodel added in v0.6.9

func (hn *Node[T]) PrintDatamodel(spacer, indent string)

func (*Node[T]) PrintFlow added in v0.6.9

func (hn *Node[T]) PrintFlow(spacer, indent string)

func (*Node[T]) PrintGen added in v0.6.9

func (hn *Node[T]) PrintGen(spacer, indent string)

type Pool added in v0.6.9

type Pool struct {
	Name   string
	Number int

	Make bool
	Take bool
}
	hof/flow configuration
	@pool(<name>[,num])
  @pool(name,3) // create pool of 3
  @pool(name)   // take from pool

type Print added in v0.6.9

type Print struct {
	Level   int
	Before  bool
	Message string
	Path    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL