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

Code before:
 * 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. */
/* Version Changelog:
 *  - 1: Initial version.
 *  - 2: Changed the `compile_code` callback to support binary data in the source code.
 *  - 3: Added reset_env callback to reset both EVAL or FUNCTION scripts env.
 */
#define VALKEYMODULE_SCRIPTING_ENGINE_ABI_VERSION 3L

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
     * list of `ValkeyModuleScriptingEngineCompiledFunc` objects. */
    union {
        ValkeyModuleScriptingEngineCompileCodeFuncV1 compile_code_v1;
        ValkeyModuleScriptingEngineCompileCodeFunc compile_code;
    };
    /* Function callback to free the memory of a registered engine function. */
    ValkeyModuleScriptingEngineFreeFunctionFunc free_function;

    /* The callback function called when `FCALL` command is called on a function
     * registered in this engine. */
    ValkeyModuleScriptingEngineCallFunctionFunc call_function;

    /* Function callback to return memory overhead for a given function. */
    ValkeyModuleScriptingEngineGetFunctionMemoryOverheadFunc get_function_memory_overhead;

    /* The callback function used to reset the runtime environment used
     * by the scripting engine for EVAL scripts or FUNCTION scripts. */

Review comment (suggestion):
The `reset_env` callback isn't just added. The old reset_eval_env is replaced with this one.

Also the numbered list is formatted in a funny way, with bullet and number and colon. I think a number and a dot is a more common style.

```suggestion
 *  1. Initial version.
 *  2. Changed the `compile_code` callback to support binary data in the source code.
 *  3. Renamed reset_eval_env callback to reset_env and added an type parameter to be
       able to reset both EVAL or FUNCTION scripts env.
```

Code after:
 *
 * - `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. */
/* Version Changelog:
 *  1. Initial version.
 *  2. Changed the `compile_code` callback to support binary data in the source code.
 *  3. Renamed reset_eval_env callback to reset_env and added a type parameter to be
 *     able to reset both EVAL or FUNCTION scripts env.
 */
#define VALKEYMODULE_SCRIPTING_ENGINE_ABI_VERSION 3L

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
     * list of `ValkeyModuleScriptingEngineCompiledFunc` objects. */
    union {
        ValkeyModuleScriptingEngineCompileCodeFuncV1 compile_code_v1;
        ValkeyModuleScriptingEngineCompileCodeFunc compile_code;
    };
    /* Function callback to free the memory of a registered engine function. */
    ValkeyModuleScriptingEngineFreeFunctionFunc free_function;

    /* The callback function called when `FCALL` command is called on a function
     * registered in this engine. */
    ValkeyModuleScriptingEngineCallFunctionFunc call_function;

    /* Function callback to return memory overhead for a given function. */
    ValkeyModuleScriptingEngineGetFunctionMemoryOverheadFunc get_function_memory_overhead;