Documentation
¶
Index ¶
Constants ¶
View Source
const ( EntryLinkFrom = "__EXTERNAL_SIGNAL__" EndLinkTo = EndNeuronID )
View Source
const (
EndNeuronID = "__END_NEURON__"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blueprint ¶
type Blueprint interface {
GetID() string
GetLabels() map[string]string
SetLabels(labels map[string]string)
GetNeuron(neuronID string) (Neuron, error)
HasNeuron(neuronID string) bool
ListNeurons() []Neuron
GetSrcNeuron(linkID string) (Neuron, error)
GetDestNeuron(linkID string) (Neuron, error)
GetLink(linkID string) (Link, error)
HasLink(linkID string) bool
HasEntryLink() bool
HasEndLink() bool
ListLinks() []Link
ListEntryLinks() []Link
ListEndLinks() []Link
ListInLinks(neuronID string) []Link
ListOutLinks(neuronID string) []Link
AddNeuron(processFn func(bc processor.BrainContext) error, withOpts ...NeuronOption) Neuron
AddNeuronWithProcessor(processor processor.Processor, withOpts ...NeuronOption) Neuron
AddLink(from, to Neuron, withOpts ...LinkOption) (Link, error)
AddEntryLinkTo(neuron Neuron, withOpts ...LinkOption) (Link, error)
AddEndLinkFrom(neuron Neuron, withOpts ...LinkOption) (Link, error)
Clone() Blueprint
}
type Brain ¶
type Brain interface {
TrigLinks(links ...Link) error
Entry() error
EntryWithMemory(keysAndValues ...any) error
// SetMemory set memories for brain, one key value pair is one memory.
// memory will lazy initial util `SetMemory` or any link trig
SetMemory(keysAndValues ...any) error
// GetMemory get memory by key
GetMemory(key any) any
// ExistMemory indicates whether there is a memory in the brain
ExistMemory(key any) bool
// DeleteMemory delete one memory by key
DeleteMemory(key any)
// ClearMemory clear all memories
ClearMemory()
// GetState get brain state
GetState() BrainState
// Wait wait util brain maintainer shutdown, which means brain state is `Sleeping`
Wait()
// Shutdown the brain
Shutdown()
}
type BrainState ¶
type BrainState string
const ( // BrainStateShutdown brain BrainStateShutdown BrainState = "Shutdown" BrainStateSleeping BrainState = "Sleeping" BrainStateRunning BrainState = "Running" )
type LinkOption ¶
type LinkOption interface {
Apply(link Link)
}
LinkOption configures a link.
func WithLinkLabels ¶
func WithLinkLabels(labels map[string]string) LinkOption
WithLinkLabels sets the specific labels for Link
type MultiLangBlueprint ¶
type MultiLangBlueprint interface {
Blueprint
// AddNeuronWithPyProcessor add a neuron with a python processor
AddNeuronWithPyProcessor(pyCodePath, moduleName, processorClassName string, constructorArgs map[string]interface{}, withOpts ...NeuronOption) Neuron
}
MultiLangBlueprint is extension interface of Blueprint, it is used for supporting multi-language blueprint
type Neuron ¶
type Neuron interface {
GetID() string
GetLabels() map[string]string
GetProcessor() processor.Processor
GetSelector() processor.Selector
ListInLinkIDs() []string
ListOutLinkIDs() []string
ListTriggerGroups() map[string][]string
ListCastGroups() map[string][]string
SetLabels(labels map[string]string)
AddTriggerGroup(links ...Link) error
AddCastGroup(groupName string, links ...Link) error
BindCastGroupSelectFunc(selectFn func(bcr processor.BrainContextReader) string)
BindCastGroupSelector(selector processor.Selector)
}
type NeuronOption ¶
type NeuronOption interface {
Apply(neuron Neuron)
}
NeuronOption configures a neuron.
func WithNeuronLabels ¶
func WithNeuronLabels(labels map[string]string) NeuronOption
WithNeuronLabels sets the specific labels for Neuron
func WithPyProcessExecCmd ¶
func WithPyProcessExecCmd(pythonCmd string) NeuronOption
WithPyProcessExecCmd sets the specific python command for Neuron
func WithSelectFn ¶
func WithSelectFn(selectFn func(brain processor.BrainContextReader) string) NeuronOption
WithSelectFn sets the specific selectFn for Neuron
func WithSelector ¶
func WithSelector(selector processor.Selector) NeuronOption
WithSelector sets the specific WithSelector for Neuron
type NeuronState ¶
type NeuronState string
const ( NeuronStateInactive NeuronState = "Inactive" NeuronStateActivated NeuronState = "Active" )
Click to show internal directories.
Click to hide internal directories.