[PATCH v1 6/8] box: export _func functions with box.func folder
Vladimir Davydov
vdavydov.dev at gmail.com
Mon Jun 3 19:22:15 MSK 2019
On Thu, May 30, 2019 at 01:45:33PM +0300, Kirill Shcherbatov wrote:
> Closes #4182
> Needed for #1260
>
> @TarantoolBot document
> Title: Persistent Lua functions
>
> Lua functions managed by Tarantool are called 'persistent'.
> They are stored in snapshoot and are available after server
> restart.
> Persistent Lua functions are exported in box.schema.func.persistent
> folder. They may be called via .call exported object method or
> via netbox:call.
>
> Some restrictions must be accounted writing such routines:
> 1. only limited set of Lua functions and modules are available:
> -assert -error -pairs -ipairs -next -pcall -xpcall -type
> -print -select -string -tonumber -tostring -unpack -math -utf8;
> 2. global variables are forbidden.
>
> Moreover all functions and their metadata are now exported in
> box.func table (not only persistent). Persistent Lua functions
> have box.func.FUNCNAME.call() method to execute it in interactive
> console.
> Persistent Lua functions are also available with net.box call.
>
> Example:
> lua_code = [[function(a, b) return a + b end]]
> box.schema.func.create('sum', {
> body = lua_code, is_deterministic = true,
> returns = 'integer', is_deterministic = true})
> box.func.sum
> - call: 'function: 0x4016b6a0'
> returns: integer
> is_deterministic: true
> id: 2
> language: LUA
> name: sum
> is_persistent: true
> setuid: false
>
> box.func.sum.call(1, 2)
I think 'call' should work for all kinds of functions, not only
persistent. That is, this should probably be the first patch in
the series.
Also, I'd expect 'call' to be a method of the function class:
box.func.sum:call(1, 2)
More information about the Tarantool-patches
mailing list