Documentation
¶
Index ¶
- type Engine
- type Option
- type Request
- func (request *Request) Call(args ...interface{}) (interface{}, error)
- func (request *Request) RootCall(args ...interface{}) (interface{}, error)
- func (request *Request) WithContext(context context.Context) *Request
- func (request *Request) WithGlobal(data map[string]interface{}) *Request
- func (request *Request) WithSid(sid string) *Request
- type Runtime
- func (runtime *Runtime) AddFunction(name string, ...) *Runtime
- func (runtime *Runtime) AddObject(name string, ...) *Runtime
- func (runtime *Runtime) AddRootFunction(name string, ...) *Runtime
- func (runtime *Runtime) Has(name string) bool
- func (runtime *Runtime) Init() error
- func (runtime *Runtime) Load(filename string, name string) error
- func (runtime *Runtime) LoadReader(reader io.Reader, name string, filename ...string) error
- func (runtime *Runtime) New(name string, method string) *Request
- func (runtime *Runtime) RootLoad(filename string, name string) error
- func (runtime *Runtime) RootReader(reader io.Reader, name string, filename ...string) error
- type Script
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine interface {
Load(filename string, name string) error
LoadReader(reader io.Reader, name string, filename ...string) error
RootLoad(filename string, name string) error
RootLoadReader(reader io.Reader, name string, filename ...string) error
AddFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error
AddRootFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error
AddObject(name string, methods map[string]func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error
Init() error
Has(name string) bool
Call(data map[string]interface{}, name string, method string, args ...interface{}) (interface{}, error)
RootCall(data map[string]interface{}, name string, method string, args ...interface{}) (interface{}, error)
}
Engine 脚本接口
type Option ¶ added in v0.10.2
type Option struct {
FileRoot string `json:"fileRoot,omitempty"` // fileRoot
WorkerNums int `json:"workerNums,omitempty"` // workerNums
}
Option the runtime option
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request 请求
func (*Request) WithContext ¶
WithContext with context
func (*Request) WithGlobal ¶
WithGlobal with global data
type Runtime ¶
Runtime 运行时
func (*Runtime) AddFunction ¶
func (runtime *Runtime) AddFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) *Runtime
AddFunction add a global JavaScript function
func (*Runtime) AddObject ¶
func (runtime *Runtime) AddObject(name string, methods map[string]func(global map[string]interface{}, sid string, args ...interface{}) interface{}) *Runtime
AddObject add a global JavaScript object
func (*Runtime) AddRootFunction ¶ added in v0.10.2
func (runtime *Runtime) AddRootFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) *Runtime
AddRootFunction add a global JavaScript function (root only)
func (*Runtime) LoadReader ¶
LoadReader load and compile script
Click to show internal directories.
Click to hide internal directories.