Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH v2 4/9] box: rework func object as a function frontend
Date: Mon, 10 Jun 2019 13:32:47 +0300	[thread overview]
Message-ID: <20190610103247.d7aisnd6ibilkfvv@esperanza> (raw)
In-Reply-To: <8902e130a9cd1ac295391fc9cd315ad4cfa2bafa.1559822429.git.kshcherbatov@tarantool.org>

On Thu, Jun 06, 2019 at 03:04:00PM +0300, Kirill Shcherbatov wrote:
> diff --git a/src/box/func.c b/src/box/func.c
> +/** Private virtual method table for func object. */
> +struct func_vtab {
> +	/** Load function runtime environment. */
> +	int (*load)(struct func *func);

'load' could be a part of 'call' or constructor.

> +	/** Unload function runtime environment. */
> +	void (*unload)(struct func *func);

Let's call this 'destroy' and call it from func_delete.

> +	/** Call function with given arguments. */
> +	int (*call)(struct func *func, struct port *port, const char *args,
> +		    const char *args_end);
> +	/**
> +	 * Capture a given old_func's runtime and reuse in a given
> +	 * new function if possible.
> +	 */
> +	void (*reuse_runtime)(struct func *new_func, struct func *old_func);
> +};

If we drop func_update, we won't need this method.

> +int
> +box_func_execute_by_name(const char *name, uint32_t name_len, struct port *port,
> +			 const char *args, const char *args_end)
> +{

I think this should live in src/box/call.c:

	box_process_call:

	- look up function by name
	- if found call it
	- otherwise check X permission on Universe and call function by
	  name using the corresponding helper defined in box/lua/call.c.

> diff --git a/src/box/func.h b/src/box/func.h
> index 82ac046b7..931718bba 100644
> --- a/src/box/func.h
> +++ b/src/box/func.h
> @@ -42,6 +42,9 @@
>  extern "C" {
>  #endif /* defined(__cplusplus) */
>  
> +struct port;
> +struct func_vtab;
> +
>  /**
>   * Dynamic shared module.
>   */
> @@ -61,6 +64,8 @@ struct module {
>   */
>  struct func {
>  	struct func_def *def;
> +	/** Virtual method table. */
> +	struct func_vtab *vtab;
>  	/**
>  	 * Anchor for module membership.
>  	 */
> @@ -68,7 +73,7 @@ struct func {
>  	/**
>  	 * For C functions, the body of the function.
>  	 */
> -	box_function_f func;
> +	box_function_f c_func;

I think it would be better to inherit the base struct so as not to mix
C/Lua stuff in the same struct:

	struct func {
		struct func_vtab *def;
		...
	};

	struct func_c {
		struct func base;
		box_function_f func;
		struct rlist in_module;
		...
	};

  reply	other threads:[~2019-06-10 10:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 12:03 [PATCH v2 0/9] box: rework functions machinery Kirill Shcherbatov
2019-06-06 12:03 ` [PATCH v2 1/9] box: refactor box_lua_find helper Kirill Shcherbatov
2019-06-10  9:17   ` Vladimir Davydov
2019-06-06 12:03 ` [PATCH v2 2/9] box: move box_module_reload routine to func.c Kirill Shcherbatov
2019-06-10  9:19   ` Vladimir Davydov
2019-06-06 12:03 ` [PATCH v2 3/9] box: rework func cache update machinery Kirill Shcherbatov
2019-06-10  9:44   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 4/9] box: rework func object as a function frontend Kirill Shcherbatov
2019-06-10 10:32   ` Vladimir Davydov [this message]
2019-06-06 12:04 ` [PATCH v2 5/9] schema: rework _func system space format Kirill Shcherbatov
2019-06-10 12:10   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 6/9] box: load persistent Lua functions on creation Kirill Shcherbatov
2019-06-10 12:19   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 7/9] box: sandbox option for persistent functions Kirill Shcherbatov
2019-06-10 14:06   ` Vladimir Davydov
2019-06-10 14:15     ` [tarantool-patches] " Kirill Shcherbatov
2019-06-10 14:41       ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 8/9] box: implement lua_port dump to region and to Lua Kirill Shcherbatov
2019-06-10 14:24   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 9/9] box: export _func functions with box.func folder Kirill Shcherbatov
2019-06-10 15:18   ` Vladimir Davydov
2019-06-10  9:14 ` [PATCH v2 0/9] box: rework functions machinery Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190610103247.d7aisnd6ibilkfvv@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 4/9] box: rework func object as a function frontend' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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