core

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 9

Documentation

Index

Constants

View Source
const (
	TYPE_GENERIC   = iota
	TYPE_PRIMITIVE = iota
	TYPE_TRIGGER   = iota
	TYPE_NUMBER    = iota
	TYPE_STRING    = iota
	TYPE_BINARY    = iota
	TYPE_BOOLEAN   = iota
	TYPE_STREAM    = iota
	TYPE_MAP       = iota
)
View Source
const (
	DIRECTION_IN  = iota
	DIRECTION_OUT = iota
)

Variables

View Source
var CHANNEL_DYNAMIC = false
View Source
var CHANNEL_SIZE = 1 << 15
View Source
var MAIN_SERVICE = "main"
View Source
var PHMultiple = &PH{"[...]"}
View Source
var PHSingle = &PH{"..."}

Functions

func CleanValue added in v0.1.17

func CleanValue(v interface{}) interface{}

func ExpandExpression

func ExpandExpression(expr string, props Properties, propDefs TypeDefMap) ([]string, error)

func IsBOS added in v0.1.17

func IsBOS(item interface{}) bool

func IsEOS added in v0.1.17

func IsEOS(item interface{}) bool

func IsMarker

func IsMarker(item interface{}) bool

Types

type BOS

type BOS struct {
	// contains filtered or unexported fields
}

type Binary added in v0.1.17

type Binary []byte

func (Binary) MarshalJSON added in v0.1.17

func (b Binary) MarshalJSON() ([]byte, error)

func (*Binary) MarshalYAML added in v0.1.17

func (b *Binary) MarshalYAML() (interface{}, error)

func (*Binary) UnmarshalJSON added in v0.1.17

func (b *Binary) UnmarshalJSON(bytes []byte) error

type Blueprint added in v0.1.17

type Blueprint struct {
	Id uuid.UUID `json:"id" yaml:"id"`

	ServiceDefs  map[string]*ServiceDef  `json:"services,omitempty" yaml:"services,omitempty"`
	DelegateDefs map[string]*DelegateDef `json:"delegates,omitempty" yaml:"delegates,omitempty"`
	InstanceDefs InstanceDefList         `json:"operators,omitempty" yaml:"operators,omitempty"`
	PropertyDefs TypeDefMap              `json:"properties,omitempty" yaml:"properties,omitempty"`
	Connections  map[string][]string     `json:"connections,omitempty" yaml:"connections,omitempty"`
	Elementary   uuid.UUID               `json:"-" yaml:"-"`

	Meta      BlueprintMetaDef `json:"meta" yaml:"meta"`
	TestCases []TestCaseDef    `json:"tests,omitempty" yaml:"tests,omitempty"`

	Geometry *struct {
		Size struct {
			Width  float32 `json:"width" yaml:"width"`
			Height float32 `json:"height" yaml:"height"`
		} `json:"size" yaml:"size"`
	} `json:"geometry,omitempty" yaml:"geometry,omitempty"`
	// contains filtered or unexported fields
}

func ParseJSONOperatorDef added in v0.1.17

func ParseJSONOperatorDef(defStr string) (Blueprint, error)

func ParseYAMLOperatorDef added in v0.1.17

func ParseYAMLOperatorDef(defStr string) (Blueprint, error)

func (Blueprint) Copy added in v0.1.17

func (d Blueprint) Copy(recursive bool) Blueprint

func (Blueprint) GenericsSpecified added in v0.1.17

func (d Blueprint) GenericsSpecified() error

func (*Blueprint) SpecifyGenericPorts added in v0.1.17

func (d *Blueprint) SpecifyGenericPorts(generics map[string]*TypeDef) error

SpecifyGenerics replaces generic types in the operator definition with the types given in the generics map. The values of the map are the according identifiers. It does not touch referenced values such as *TypeDef but replaces them with a reference on a copy.

func (*Blueprint) SpecifyOperator added in v0.1.17

func (def *Blueprint) SpecifyOperator(gens Generics, props Properties) error

func (Blueprint) Valid added in v0.1.17

func (d Blueprint) Valid() bool

func (*Blueprint) Validate added in v0.1.17

func (d *Blueprint) Validate() error

type BlueprintMetaDef added in v0.1.17

type BlueprintMetaDef struct {
	Name             string   `json:"name" yaml:"name"`
	Icon             string   `json:"icon" yaml:"icon"`
	ShortDescription string   `json:"shortDescription" yaml:"shortDescription"`
	Description      string   `json:"description" yaml:"description"`
	DocURL           string   `json:"docUrl" yaml:"docUrl"`
	Tags             []string `json:"tags" yaml:"tags"`
	// contains filtered or unexported fields
}

func (*BlueprintMetaDef) Valid added in v0.1.17

func (d *BlueprintMetaDef) Valid() bool

func (*BlueprintMetaDef) Validate added in v0.1.17

func (d *BlueprintMetaDef) Validate() error

type CFunc

type CFunc func(op *Operator, dst, src *Port) error

type Delegate

type Delegate struct {
	// contains filtered or unexported fields
}

func NewDelegate

func NewDelegate(name string, op *Operator, def DelegateDef) (*Delegate, error)

func (*Delegate) Define

func (d *Delegate) Define() DelegateDef

func (*Delegate) In

func (d *Delegate) In() *Port

func (*Delegate) Name

func (d *Delegate) Name() string

func (*Delegate) Operator

func (d *Delegate) Operator() *Operator

func (*Delegate) Out

func (d *Delegate) Out() *Port

type DelegateDef

type DelegateDef struct {
	In  TypeDef `json:"in" yaml:"in"`
	Out TypeDef `json:"out" yaml:"out"`

	Geometry *PortGeometryDef `json:"geometry,omitempty" yaml:"geometry,omitempty"`
	// contains filtered or unexported fields
}

func (DelegateDef) Copy

func (d DelegateDef) Copy() DelegateDef

func (*DelegateDef) Valid

func (d *DelegateDef) Valid() bool

func (*DelegateDef) Validate

func (d *DelegateDef) Validate() error

type EOS

type EOS struct {
	// contains filtered or unexported fields
}

type Generics

type Generics map[string]*TypeDef

type InstanceDef

type InstanceDef struct {
	Name     string    `json:"-" yaml:"-"`
	Operator uuid.UUID `json:"operator" yaml:"operator"`

	Properties Properties `json:"properties,omitempty" yaml:"properties,omitempty"`
	Generics   Generics   `json:"generics,omitempty" yaml:"generics,omitempty"`

	Geometry *struct {
		Position struct {
			X float32 `json:"x" yaml:"x"`
			Y float32 `json:"y" yaml:"y"`
		} `json:"position" yaml:"position"`
	} `json:"geometry,omitempty" yaml:"geometry,omitempty"`

	Blueprint Blueprint `json:"-" yaml:"definition,omitempty"`
	// contains filtered or unexported fields
}

func (InstanceDef) Copy added in v0.1.17

func (d InstanceDef) Copy(recursive bool) InstanceDef

func (InstanceDef) Valid

func (d InstanceDef) Valid() bool

func (*InstanceDef) Validate

func (d *InstanceDef) Validate() error

type InstanceDefList

type InstanceDefList []*InstanceDef

func (InstanceDefList) MarshalJSON

func (ol InstanceDefList) MarshalJSON() ([]byte, error)

func (InstanceDefList) MarshalYAML

func (ol InstanceDefList) MarshalYAML() (interface{}, error)

func (*InstanceDefList) UnmarshalJSON

func (ol *InstanceDefList) UnmarshalJSON(data []byte) error

func (*InstanceDefList) UnmarshalYAML

func (ol *InstanceDefList) UnmarshalYAML(unmarshal func(v interface{}) error) error

type MapStr added in v0.1.17

type MapStr map[string]interface{}

func (*MapStr) UnmarshalYAML added in v0.1.17

func (ms *MapStr) UnmarshalYAML(unmarshal func(interface{}) error) error

type OFunc

type OFunc func(op *Operator)

type Operator

type Operator struct {
	// contains filtered or unexported fields
}

func NewOperator

func NewOperator(name string, f OFunc, c CFunc, gens Generics, props Properties, def Blueprint) (*Operator, error)

func (*Operator) BasePort

func (o *Operator) BasePort() *Port

func (*Operator) Builtin

func (o *Operator) Builtin() bool

func (*Operator) CheckStop

func (o *Operator) CheckStop() bool

func (*Operator) Child

func (o *Operator) Child(name string) *Operator

func (*Operator) Children

func (o *Operator) Children() map[string]*Operator

func (*Operator) Compile

func (o *Operator) Compile() (compiled int, depth int)

func (*Operator) CorrectlyCompiled

func (o *Operator) CorrectlyCompiled() error

func (*Operator) Define

func (o *Operator) Define() (Blueprint, error)

func (*Operator) Delegate

func (o *Operator) Delegate(del string) *Delegate

func (*Operator) Id added in v0.1.17

func (o *Operator) Id() uuid.UUID

func (*Operator) Main

func (o *Operator) Main() *Service

func (*Operator) Name

func (o *Operator) Name() string

func (*Operator) Parent

func (o *Operator) Parent() *Operator

func (*Operator) Property

func (o *Operator) Property(prop string) interface{}

func (*Operator) Service

func (o *Operator) Service(srv string) *Service

func (*Operator) SetParent

func (o *Operator) SetParent(par *Operator)

func (*Operator) SetProperties

func (o *Operator) SetProperties(properties Properties)

func (*Operator) Start

func (o *Operator) Start()

func (*Operator) Stop

func (o *Operator) Stop()

func (*Operator) Stopped added in v0.1.8

func (o *Operator) Stopped() bool

func (*Operator) WaitForStop

func (o *Operator) WaitForStop()

type PH added in v0.1.8

type PH struct {
	// contains filtered or unexported fields
}

func (*PH) MarshalJSON added in v0.1.8

func (ph *PH) MarshalJSON() ([]byte, error)

type Port

type Port struct {
	// contains filtered or unexported fields
}

func NewPort

func NewPort(srv *Service, del *Delegate, def TypeDef, dir int) (*Port, error)

Makes a new port.

func ParsePortReference added in v0.1.17

func ParsePortReference(refStr string, par *Operator) (*Port, error)

func (*Port) Bufferize

func (p *Port) Bufferize()

func (*Port) Close

func (p *Port) Close()

Closes the port by closing all channels

func (*Port) Closed added in v0.1.17

func (p *Port) Closed() bool

func (*Port) Connect

func (p *Port) Connect(q *Port) (err error)

Connects this port with port p.

func (*Port) Connected

func (p *Port) Connected(q *Port) bool

Returns true if p is connected with q.

func (*Port) Define

func (p *Port) Define() TypeDef

func (*Port) Delegate

func (p *Port) Delegate() *Delegate

Returns the operator this port is attached to

func (*Port) Direction

func (p *Port) Direction() int

Returns the direction of the port.

func (*Port) DirectlyConnected

func (p *Port) DirectlyConnected() error

Checks if this in port is connected completely

func (*Port) Disconnect

func (p *Port) Disconnect(q *Port) error

Disconnects this port from port q.

func (*Port) Map

func (p *Port) Map(name string) *Port

Returns the subport with the according name of this port. Port must be of type map.

func (*Port) MapEntryNames added in v0.1.17

func (p *Port) MapEntryNames() []string

Returns all map entry names of this port

func (*Port) MapLength added in v0.1.17

func (p *Port) MapLength() int

Returns the length of the map ports

func (*Port) MapType added in v0.1.17

func (p *Port) MapType() bool

func (*Port) Merge

func (p *Port) Merge() bool

Removes this port and redirects connections.

func (*Port) Name

func (p *Port) Name() string

Name returns a name generated from operator, directions and port.

func (*Port) NewBOS

func (p *Port) NewBOS() BOS

func (*Port) NewEOS

func (p *Port) NewEOS() EOS

func (*Port) Open

func (p *Port) Open()

Opens the port by opening all channels

func (*Port) Operator

func (p *Port) Operator() *Operator

Returns the operator this port is attached to

func (*Port) OwnBOS

func (p *Port) OwnBOS(i interface{}) bool

func (*Port) OwnEOS

func (p *Port) OwnEOS(i interface{}) bool

func (*Port) ParentStream

func (p *Port) ParentStream() *Port

Returns the parent stream port. Port must be of type stream.

func (*Port) Poll

func (p *Port) Poll() interface{}

Similar to Port.Pull but will return nil when there is no item after timeout

func (*Port) PrimitiveType added in v0.1.17

func (p *Port) PrimitiveType() bool

func (*Port) Pull

func (p *Port) Pull() interface{}

Pull an item from this port

func (*Port) PullBOS

func (p *Port) PullBOS() bool

func (*Port) PullBinary

func (p *Port) PullBinary() (Binary, interface{})

Pull a binary object

func (*Port) PullBoolean

func (p *Port) PullBoolean() (bool, interface{})

Pull an boolean

func (*Port) PullEOS

func (p *Port) PullEOS() bool

func (*Port) PullFloat64

func (p *Port) PullFloat64() (float64, interface{})

Pull a float

func (*Port) PullInt

func (p *Port) PullInt() (int, interface{})

Pull an int

func (*Port) PullString

func (p *Port) PullString() (string, interface{})

Pull a string

func (*Port) Push

func (p *Port) Push(item interface{})

Push an item to this port.

func (*Port) PushBOS

func (p *Port) PushBOS()

func (*Port) PushEOS

func (p *Port) PushEOS()

func (*Port) PushNoTriggerBOS

func (p *Port) PushNoTriggerBOS()

func (*Port) SetStreamSource

func (p *Port) SetStreamSource(srcStr *Port)

func (*Port) Stream

func (p *Port) Stream() *Port

Returns the substream port of this port. Port must be of type stream.

func (*Port) StreamSource

func (p *Port) StreamSource() *Port

func (*Port) String added in v0.1.17

func (p *Port) String() string

func (*Port) TriggerType added in v0.1.17

func (p *Port) TriggerType() bool

func (*Port) Type

func (p *Port) Type() int

Returns the type of the port.

func (*Port) WalkPrimitivePorts added in v0.1.17

func (p *Port) WalkPrimitivePorts(handle func(p *Port))

type PortGeometryDef added in v0.1.15

type PortGeometryDef struct {
	In struct {
		Position float32 `json:"position" yaml:"position"`
	} `json:"in" yaml:"in"`
	Out struct {
		Position float32 `json:"position" yaml:"position"`
	} `json:"out" yaml:"out"`
}

type Properties

type Properties MapStr

func (Properties) Clean

func (p Properties) Clean()

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, op *Operator, def ServiceDef) (*Service, error)

func (*Service) Define

func (s *Service) Define() ServiceDef

func (*Service) In

func (s *Service) In() *Port

func (*Service) Name

func (s *Service) Name() string

func (*Service) Operator

func (s *Service) Operator() *Operator

func (*Service) Out

func (s *Service) Out() *Port

type ServiceDef

type ServiceDef struct {
	In  TypeDef `json:"in" yaml:"in"`
	Out TypeDef `json:"out" yaml:"out"`

	Geometry *PortGeometryDef `json:"geometry,omitempty" yaml:"geometry,omitempty"`
	// contains filtered or unexported fields
}

func (ServiceDef) Copy

func (d ServiceDef) Copy() ServiceDef

func (*ServiceDef) Valid

func (d *ServiceDef) Valid() bool

func (*ServiceDef) Validate

func (d *ServiceDef) Validate() error

type SlangBundle added in v0.1.17

type SlangBundle struct {
	Main uuid.UUID `json:"main" yaml:"main"`

	Args struct {
		Properties Properties `json:"properties,omitempty" yaml:"properties,omitempty"`
		Generics   Generics   `json:"generics,omitempty" yaml:"generics,omitempty"`
	} `json:"args,omitempty"`

	Blueprints map[uuid.UUID]Blueprint `json:"blueprints"`
	// contains filtered or unexported fields
}

func (SlangBundle) Valid added in v0.1.17

func (sb SlangBundle) Valid() bool

func (*SlangBundle) Validate added in v0.1.17

func (sb *SlangBundle) Validate() error

type Synchronizer

type Synchronizer struct {
	// contains filtered or unexported fields
}

func (*Synchronizer) Init

func (s *Synchronizer) Init(in, out *Port)

func (*Synchronizer) Pull

func (s *Synchronizer) Pull(token int64, pull pullFunc)

func (*Synchronizer) Push

func (s *Synchronizer) Push(push pushFunc) int64

func (*Synchronizer) Worker

func (s *Synchronizer) Worker()

type TestCaseDef added in v0.1.17

type TestCaseDef struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description" yaml:"description"`

	Generics   Generics   `json:"generics" yaml:"generics"`
	Properties Properties `json:"properties" yaml:"properties"`

	Data struct {
		In  []interface{} `json:"in" yaml:"in"`
		Out []interface{} `json:"out" yaml:"out"`
	}
	// contains filtered or unexported fields
}

func (TestCaseDef) Valid added in v0.1.17

func (tc TestCaseDef) Valid() bool

func (*TestCaseDef) Validate added in v0.1.17

func (tc *TestCaseDef) Validate() error

type TypeDef

type TypeDef struct {
	// Type is one of "primitive", "number", "string", "boolean", "stream", "map", "generic"
	Type     string     `json:"type" yaml:"type"`
	Stream   *TypeDef   `json:"stream,omitempty" yaml:"stream,omitempty"`
	Map      TypeDefMap `json:"map,omitempty" yaml:"map,omitempty"`
	Generic  string     `json:"generic,omitempty" yaml:"generic,omitempty"`
	Optional bool       `json:"optional,omitempty" yaml:"optional,omitempty"`
	// contains filtered or unexported fields
}

func ParseTypeDef added in v0.1.17

func ParseTypeDef(defStr string) TypeDef

func (*TypeDef) ApplyProperties

func (d *TypeDef) ApplyProperties(props Properties, propDefs map[string]*TypeDef) error

func (TypeDef) Copy

func (d TypeDef) Copy() TypeDef

func (TypeDef) Equals

func (d TypeDef) Equals(p TypeDef) bool

func (TypeDef) GenericsSpecified

func (d TypeDef) GenericsSpecified() error

func (*TypeDef) SpecifyGenerics

func (d *TypeDef) SpecifyGenerics(generics map[string]*TypeDef) error

SpecifyGenerics replaces generic types in the port definition with the types given in the generics map. The values of the map are the according identifiers. It does not touch referenced values such as *TypeDef but replaces them with a reference on a copy, which is very important to prevent unintended side effects.

func (*TypeDef) Valid

func (d *TypeDef) Valid() bool

func (*TypeDef) Validate

func (d *TypeDef) Validate() error

func (TypeDef) VerifyData

func (d TypeDef) VerifyData(data interface{}) error

type TypeDefMap

type TypeDefMap map[string]*TypeDef

func (TypeDefMap) GenericsSpecified

func (t TypeDefMap) GenericsSpecified() error

func (TypeDefMap) SpecifyGenerics

func (t TypeDefMap) SpecifyGenerics(generics map[string]*TypeDef) error

func (TypeDefMap) VerifyData

func (t TypeDefMap) VerifyData(data map[string]interface{}) error

Jump to

Keyboard shortcuts

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