[Tarantool-patches] [RFC] cmod user api
gorcunov at gmail.com
Mon Jan 25 23:35:50 MSK 2021
Hi guys! Recently I've sent a series which implements that
named "cmod" module which allows to load and run stored C
procedures similar to 'box.func' except they allows to run
such functions even on nodes in read-only mode.
The overall picture of api was not clear from changelog and
here I provide a short description to gather comments.
Entry point of any function comes from "module" instance.
To load a module one have to
module = require('cmod').load('path-to-module')
Note the path to the module should be shipped without .so
extension (or dylib for macos). I suspect we should support
both variants with and without file extension.
Once module is loaded we can associate a function from
this module with some Lua variable.
foo = module:load('name-of-function')
Then we can execute it
res = foo(arguments, ...)
Both function and module supports explicit unloading via
When function/module is unloaded any attempt to use this
variable will produce an error. If they are not explicitly
unloaded then GC will reap them.
Module Lua object provides :reload() method which re-reads
the shared library and updates associated functions such than
any new call will be executed via new code. If there are some
already executing functions which are in yield state then such
functions gonna finish execution of old code first and only
next calls will be pacing the new code.
Does such api looks sane or there some other ideas?
More information about the Tarantool-patches