Documentation ¶
Index ¶
- Variables
- type Ankiddie
- func (ssys *Ankiddie) Environment(eid uint) (*Environment, bool)
- func (ssys *Ankiddie) Environments() map[uint]*Environment
- func (ssys *Ankiddie) ForgetEnv(env *Environment)
- func (ssys *Ankiddie) FullReset()
- func (ssys *Ankiddie) NewEnvWithCode(code string, out func(env *Environment, msg string) error) *Environment
- func (ssys *Ankiddie) NewEnvWithScript(script *Script, out func(env *Environment, msg string) error) *Environment
- func (ssys *Ankiddie) SaveScript(id string, code string) (*Script, error)
- func (ssys *Ankiddie) StartAutorun(level int, async bool, out func(env *Environment, msg string) error) error
- type Environment
- func (env *Environment) Dirty() bool
- func (env *Environment) EID() uint
- func (env *Environment) Execute(source string, appendToSrc bool) (interface{}, error)
- func (env *Environment) Forget()
- func (env *Environment) Restart() (interface{}, error)
- func (env *Environment) SaveScript(id string) (*Script, error)
- func (env *Environment) ScriptID() string
- func (env *Environment) Start() (interface{}, error)
- func (env *Environment) Started() bool
- func (env *Environment) Suspend() error
- func (env *Environment) Suspended() bool
- type PackageConfigurator
- type Script
- type ScriptLoader
- type ScriptPersister
- type ScriptStorer
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyStarted = errors.New("environment already started")
ErrAlreadyStarted when an environment had already been started
var ErrAlreadySuspended = errors.New("environment already suspended")
ErrAlreadySuspended when an environment is already suspended
var ErrNoPersister = errors.New("script persister not specified")
ErrNoPersister when a script persister is not specified
Functions ¶
This section is empty.
Types ¶
type Ankiddie ¶
type Ankiddie struct {
// contains filtered or unexported fields
}
Ankiddie manages the execution of anko scripts
func New ¶
func New(configurator PackageConfigurator, store ScriptPersister) *Ankiddie
New returns a new Ankiddie
func (*Ankiddie) Environment ¶
func (ssys *Ankiddie) Environment(eid uint) (*Environment, bool)
Environment returns the environment with the given ID, if one exists
func (*Ankiddie) Environments ¶
func (ssys *Ankiddie) Environments() map[uint]*Environment
Environments returns a map with the currently registered environments
func (*Ankiddie) ForgetEnv ¶
func (ssys *Ankiddie) ForgetEnv(env *Environment)
ForgetEnv stops execution of the given environment as far as possible and unregisters it
func (*Ankiddie) FullReset ¶
func (ssys *Ankiddie) FullReset()
FullReset stops execution on all environments and destroys them
func (*Ankiddie) NewEnvWithCode ¶
func (ssys *Ankiddie) NewEnvWithCode(code string, out func(env *Environment, msg string) error) *Environment
NewEnvWithCode returns a new Environment ready to run the provided code
func (*Ankiddie) NewEnvWithScript ¶
func (ssys *Ankiddie) NewEnvWithScript(script *Script, out func(env *Environment, msg string) error) *Environment
NewEnvWithScript returns a new Environment ready to run the provided Script
func (*Ankiddie) SaveScript ¶
SaveScript saves a script to the database under the specified ID If no ID is provided, a UUID is generated If a script with the same ID already existed, it is overwritten
func (*Ankiddie) StartAutorun ¶
func (ssys *Ankiddie) StartAutorun(level int, async bool, out func(env *Environment, msg string) error) error
StartAutorun executes scripts at the specified autorun level
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is a anko environment managed by Ankiddie
func (*Environment) Dirty ¶
func (env *Environment) Dirty() bool
Dirty returns whether the code associated with this environment has had changes since the environment was created
func (*Environment) Execute ¶
func (env *Environment) Execute(source string, appendToSrc bool) (interface{}, error)
Execute parses and runs source in current scope
func (*Environment) Forget ¶
func (env *Environment) Forget()
Forget stops execution of the given environment as far as possible and unregisters it
func (*Environment) Restart ¶
func (env *Environment) Restart() (interface{}, error)
Restart restarts the execution on the environment
func (*Environment) SaveScript ¶
func (env *Environment) SaveScript(id string) (*Script, error)
SaveScript saves the script to the database under the specified ID If no ID is provided, the script is saved under its original ID If the script did not have an ID associated, a UUID is generated
func (*Environment) ScriptID ¶
func (env *Environment) ScriptID() string
ScriptID returns the script ID associated with this environment
func (*Environment) Start ¶
func (env *Environment) Start() (interface{}, error)
Start parses and runs the source associated with the environment
func (*Environment) Started ¶
func (env *Environment) Started() bool
Started returns whether execution has ever started in this environment
func (*Environment) Suspend ¶
func (env *Environment) Suspend() error
Suspend stops the execution on the environment without destroying its state
func (*Environment) Suspended ¶
func (env *Environment) Suspended() bool
Suspended returns whether execution is suspended in this environment
type PackageConfigurator ¶
type PackageConfigurator interface {
ConfigurePackages(packages map[string]map[string]reflect.Value, packageTypes map[string]map[string]reflect.Type)
}
PackageConfigurator configures additional packages to expose to anko environments
type ScriptLoader ¶
type ScriptLoader interface { // GetScript should return an error if a script with the specified ID does not exist GetScript(id string) (*Script, error) GetAutorunScripts(autorunLevel int) ([]*Script, error) }
ScriptLoader loads scripts from storage
type ScriptPersister ¶
type ScriptPersister interface { ScriptLoader ScriptStorer }
ScriptPersister loads and stores scripts from storage
type ScriptStorer ¶
ScriptStorer stores scripts to storage