flo

package module
v0.0.0-...-6bd4954 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

flo

A flow-based programming thingy in Go.

Disclaimer

This module is still under heavy development and until it reaches v1 is considered unstable and unfit for production use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewComponentIOsFromComponent

func NewComponentIOsFromComponent(c *Component) error

Types

type Component

type Component struct {
	ID          uuid.UUID
	Name        string
	PkgPath     string
	Label       string
	Description string
	Value       reflect.Value // Enable use of instantiated object's methods or functions.
	IOs         IOs
}

func NewComponent

func NewComponent(
	name, pkgPath string,
	label, description string,
	fn any,
) (*Component, error)

type ComponentConnection

type ComponentConnection struct {
	ID               uuid.UUID
	OutComponentID   uuid.UUID
	OutComponentIOID uuid.UUID
	InComponentID    uuid.UUID
	InComponentIOID  uuid.UUID
}

func NewComponentConnect

func NewComponentConnect(
	outComponentID uuid.UUID,
	outComponentIOID uuid.UUID,
	inComponentID uuid.UUID,
	inComponentIOID uuid.UUID,
) (*ComponentConnection, error)

type ComponentIO

type ComponentIO struct {
	ID          uuid.UUID
	Name        string // autogenerated short id used as variable name.
	Type        ComponentIOType
	RType       reflect.Type
	IsError     bool
	ParentID    uuid.UUID              // Used for back reference.
	Connections []*ComponentConnection // Many outgoing but one incoming.
}

func NewComponentIO

func NewComponentIO(
	name string,
	typ ComponentIOType,
	rType reflect.Type,
	parentID uuid.UUID,
) (*ComponentIO, error)

type ComponentIOType

type ComponentIOType int
const (
	ComponentIOTypeUnknown ComponentIOType = iota
	ComponentIOTypeIN
	ComponentIOTypeOUT
)

func (ComponentIOType) String

func (t ComponentIOType) String() string

type Flo

type Flo struct {
	ID             uuid.UUID
	Name           string
	Label          string
	Description    string
	PkgName        string
	PkgDescription string
	Components     map[uuid.UUID]*Component
	IOs            IOs
	// contains filtered or unexported fields
}

Flo is a fancy name for a bidirectional graph with some opionionated rules. It is essentially rendered as a wrapper function declaration. IOs are just the function parameters and return values. Nodes are called components and represent function calls.

func NewFlo

func NewFlo(
	name, label, description string,
	pkgName, pkgDescription string,
) (*Flo, error)

NewFlo needs fn to make IOs creation much more pleasant.

func (*Flo) AddComponent

func (f *Flo) AddComponent(c *Component) error

func (*Flo) AddIO

func (f *Flo) AddIO(io *ComponentIO) error

func (*Flo) ConnectComponent

func (f *Flo) ConnectComponent(
	outComponentID, outComponentIOID uuid.UUID,
	inComponentID, inComponentIOID uuid.UUID,
) error

ConnectComponent inter connects components or flos.

Rules: 1. flo and component: IN(flo) -> IN(component) and OUT(component) -> OUT(flo). 2. component and component: OUT(component) -> IN(component).

func (*Flo) DeleteComponent

func (f *Flo) DeleteComponent(id uuid.UUID) error

func (*Flo) DeleteConnection

func (f *Flo) DeleteConnection(connectionID uuid.UUID) error

func (*Flo) DeleteIO

func (f *Flo) DeleteIO(id uuid.UUID) error

func (*Flo) PrettyDump

func (f *Flo) PrettyDump(w io.Writer) error

func (*Flo) Render

func (f *Flo) Render(
	ctx context.Context,
	w io.Writer,
) error

func (*Flo) RenderComponent

func (f *Flo) RenderComponent(
	ctx context.Context,
	g *jen.Group,
	c *Component,
	rendered map[uuid.UUID]struct{},
) error

func (*Flo) Symbols

func (f *Flo) Symbols() map[string]map[string]reflect.Value

type IOs

type IOs []*ComponentIO

func (IOs) GetByID

func (ios IOs) GetByID(id uuid.UUID) (*ComponentIO, bool)

func (IOs) HasConnections

func (ios IOs) HasConnections() bool

func (IOs) SeparateINsOUTs

func (ios IOs) SeparateINsOUTs() (IOs, IOs)

Jump to

Keyboard shortcuts

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