-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support registering Lua API functions on storages and routers in runtime #1799
Comments
vshard is about calling functions, crud is about accessing spaces. It looks a bit strange to duplicate support of calling functions in crud. But some enhancements for the 'calling a function' flow are proposed above, so we can discuss them out of the crud module context. (Maybe it is closer to https://github.com/tarantool/cartridge-extensions / https://github.com/tarantool/easy-function, but I'm not in context of those projects.) The example shows calling of a user-defined function on a storage ('crud-storage' role), but the function calls Calling of a function only on instances that have given cartridge role (one from a provided list) is a bit unclear too. Whether the function should be called on all instances with this role? Or on one according to ACL idea is not clear for me too. Tarantool has built-in ACL, so if we'll allows to add, say, I'll reassign the task to the Product team to elaborate a problem statement(s) and determine importance. |
@Totktonada thanks for triaging this. Let me address some of the questions you put up.
Of course, and I stated this, however, there is still no appropriate module to put this functionality into.
What example? If you speak about "JOIN" cases, they are extensions of the The main idea is to allow users and connector authors to not bother with registering the functions manually in Tarantool and roles via writing the code in roles and initialization scripts, but use some API instead for passing the function signature and ACLs and having all this set up automatically. A close example of this is the stored procedure registration commands in different SQL flavors. Here's an example of how I saw this API usage: -- In the initialization code of some Cartridge role
function init(self)
if (self.is_master)
cartridge.register('my_function(foo, bar, baz)',`{'integer', 'string', 'boolean'}`, "require('logger').error(hello)", {})
end
end
-- In the client code
tuples = cartridge.rpc_call('my_function', {1, 'abc', true}, {option = value}) -- looks a lot like the current API when
-- functions are registered manually in Tarantool
-- and called via vshard
The intention was to guarantee some "dependencies" for a function, which may be expressed in a list of enabled roles. It is for supporting the situation where only part of the nodes has some initialization code that provides local tables and necessary auxiliary functions which will be used by the registered function. Speaking about the
The proposed ACL options are for providing the users a way of setting up all the necessary access control in one place. All the necessary calls, including public API registration, grants, and possible usage of some third-party security manager are done for the user automatically, the user only specifies what needs to be done in a declarative form. However, if there are some movements towards improving the security API in Tarantool, I support that, but it has nothing with this task. |
Moved from crud to cartridge. |
Sorry no capacity for such feature right now. Gently closing. Feel free to reopen any time from everywhere. |
/* Moved from crud to cartridge. */
Problem statement
For using Tarantool Cartridge from connectors customers have to define custom roles with custom methods that perform basic manipulation with the data on storages and then call these methods by name. This makes customers writing a lot of boilerplate and duplicate code and frustrates them.
Examples of typical use-cases:
Registering custom Lua functions for typical tasks generated in connectors will help customers to spend less time on the typical tasks.
Proposed API
I think it may be implemented in a separate module or in the Cartridge itself since it is not a "CRUD" functionality.
crud.register
Registers the function on all cluster nodes.
function_signature
(string) -- function name and parameterscheck_params
(table) -- checks() call parameters for checking the passed parametersbody
(string) -- function bodyopts
(table) -- function metadata:roles
(list) -- list of Cartridge role names. The function will be available only on instances that have all of the passed roles enabledacl
(table) -- access metadata:allow
(table) -- which users/roles will be able to invoke the functionusers
(list) -- lsit of user loginsroles
(list) -- list of user role namesdeny
(table) -- which users/roles will be not able to invoke the functionusers
(list) -- lsit of user loginsroles
(list) -- list of user role namesExample:
crud.unregister
Unregisters the function on all cluster nodes.
function_signature
(string) -- function name and parametersExample:
Requirements
The text was updated successfully, but these errors were encountered: