-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc_call.lua
More file actions
36 lines (28 loc) · 797 Bytes
/
func_call.lua
File metadata and controls
36 lines (28 loc) · 797 Bytes
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
local funcs = require("funcs")
local json = require("json")
local function call(arguments)
local target = arguments.id
if not target or target == "" then
return "Error: id is required (format: namespace:name)"
end
local args = arguments.args or {}
local exec = funcs.new()
if arguments.context then
exec = exec:with_context(arguments.context)
end
if arguments.timeout then
exec = exec:with_options({timeout = arguments.timeout})
end
local result, err = exec:call(target, table.unpack(args))
if err then
return json.encode({
success = false,
error = tostring(err)
})
end
return json.encode({
success = true,
result = result
})
end
return { call = call }