-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaction.go
54 lines (44 loc) · 1018 Bytes
/
action.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package glua
import (
"context"
)
type Action struct {
script string
scriptMD5 string
scriptPath string
entrypoint string
params []interface{}
funcs map[string]LuaExternFunc
}
func NewAction() *Action {
return &Action{
params: make([]interface{}, 0),
funcs: make(map[string]LuaExternFunc, 0),
}
}
func (a *Action) WithScript(script string) *Action {
a.script = script
return a
}
func (a *Action) WithScriptMD5(md5 string) *Action {
return a
}
func (a *Action) WithScriptPath(scriptPath string) *Action {
a.scriptPath = scriptPath
return a
}
func (a *Action) WithEntrypoint(entrypoint string) *Action {
a.entrypoint = entrypoint
return a
}
func (a *Action) AddParam(params ...interface{}) *Action {
a.params = append(a.params, params...)
return a
}
func (a *Action) AddFunc(methodName string, method LuaExternFunc) *Action {
a.funcs[methodName] = method
return a
}
func (a *Action) Execute(ctx context.Context) (interface{}, error) {
return getScheduler().do(ctx, a)
}