Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [RFC] cmod user api
@ 2021-01-25 20:35 Cyrill Gorcunov via Tarantool-patches
  2021-01-25 21:08 ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-25 20:35 UTC (permalink / raw)
  To: TML; +Cc: Mons Anderson, Vladislav Shpilevoy

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
unload method.

    foo:unload()
    module:unload()

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?

	Cyrill

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-25 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 20:35 [Tarantool-patches] [RFC] cmod user api Cyrill Gorcunov via Tarantool-patches
2021-01-25 21:08 ` Vladislav Shpilevoy via Tarantool-patches
2021-01-25 21:56   ` Cyrill Gorcunov via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox