Repository: valkey-io/valkey
File: src/valkeymodule.h (C/C++)

Code before:
    ValkeyModuleString **keys,
    size_t nkeys,
    ValkeyModuleString **args,
    size_t nargs);

/* Return memory overhead for a given function, such memory is not counted as
 * engine memory but as general structs memory that hold different information
 */
typedef size_t (*ValkeyModuleScriptingEngineGetFunctionMemoryOverheadFunc)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCompiledFunction *compiled_function);

/* The callback function called when `SCRIPT FLUSH` or `FUNCTION FLUSH` command is called.
 * The engine should reset the runtime environment used for EVAL scripts or FUNCTION SCRIPTS.
 *
 * - `module_ctx`: the module runtime context.
 *
 * - `engine_ctx`: the scripting engine runtime context.
 *
 * - `type`: the subsystem type.
 *
 * - `async`: if has value 1 then the reset is done asynchronously through
 * the callback structure returned by this function.
 */
typedef ValkeyModuleScriptingEngineCallableLazyEnvReset *(*ValkeyModuleScriptingEngineResetEnvFunc)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCtx *engine_ctx,
    ValkeyModuleScriptingEngineSubsystemType type,
    int async);

/* Return the current used memory by the engine.
 *
 * - `module_ctx`: the module runtime context.
 *
 * - `engine_ctx`: the scripting engine runtime context.
 *
 * - `type`: the subsystem type.
 */
typedef ValkeyModuleScriptingEngineMemoryInfo (*ValkeyModuleScriptingEngineGetMemoryInfoFunc)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCtx *engine_ctx,
    ValkeyModuleScriptingEngineSubsystemType type);

/* Current ABI version for scripting engine modules. */
#define VALKEYMODULE_SCRIPTING_ENGINE_ABI_VERSION 2UL

typedef struct ValkeyModuleScriptingEngineMethods {
    uint64_t version; /* Version of this structure for ABI compat. */

    /* Compile code function callback. When a new script is loaded, this
     * callback will be called with the script code, compiles it, and returns a

Review comment (suggestion):
These API changes are a breaking change, and we need to version the `ValkeyModuleScriptingEngineResetEnvFunc` function pointer since its signature is changed.

Code after:
    ValkeyModuleString **keys,
    size_t nkeys,
    ValkeyModuleString **args,
    size_t nargs);

/* Return memory overhead for a given function, such memory is not counted as
 * engine memory but as general structs memory that hold different information
 */
typedef size_t (*ValkeyModuleScriptingEngineGetFunctionMemoryOverheadFunc)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCompiledFunction *compiled_function);

/* The callback function called when `SCRIPT FLUSH` command is called. The
 * engine should reset the runtime environment used for EVAL scripts.
 * This callback has been replaced by `ValkeyModuleScriptingEngineResetEnvFunc`
 * callback in ABI version 3.
 *
 * - `module_ctx`: the module runtime context.
 *
 * - `engine_ctx`: the scripting engine runtime context.
 *
 * - `async`: if has value 1 then the reset is done asynchronously through
 * the callback structure returned by this function.
 */
typedef ValkeyModuleScriptingEngineCallableLazyEnvReset *(*ValkeyModuleScriptingEngineResetEvalFuncV2)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCtx *engine_ctx,
    int async);

/* The callback function called when `SCRIPT FLUSH` or `FUNCTION FLUSH` command is called.
 * The engine should reset the runtime environment used for EVAL scripts or FUNCTION scripts.
 *
 * - `module_ctx`: the module runtime context.
 *
 * - `engine_ctx`: the scripting engine runtime context.
 *
 * - `type`: the subsystem type.
 *
 * - `async`: if has value 1 then the reset is done asynchronously through
 * the callback structure returned by this function.
 */
typedef ValkeyModuleScriptingEngineCallableLazyEnvReset *(*ValkeyModuleScriptingEngineResetEnvFunc)(
    ValkeyModuleCtx *module_ctx,
    ValkeyModuleScriptingEngineCtx *engine_ctx,
    ValkeyModuleScriptingEngineSubsystemType type,
    int async);

/* Return the current used memory by the engine.
 *
 * - `module_ctx`: the module runtime context.
 *