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

Code before:
#define VALKEYMODULE_SWAPDBINFO_VERSION 1
typedef struct ValkeyModuleSwapDbInfo {
    uint64_t version;     /* Not used since this structure is never passed
                             from the module to the core right now. Here
                             for future compatibility. */
    int32_t dbnum_first;  /* Swap Db first dbnum */
    int32_t dbnum_second; /* Swap Db second dbnum */
} ValkeyModuleSwapDbInfoV1;

#define ValkeyModuleSwapDbInfo ValkeyModuleSwapDbInfoV1

#define VALKEYMODULE_KEYINFO_VERSION 1
typedef struct ValkeyModuleKeyInfo {
    uint64_t version;     /* Not used since this structure is never passed
                             from the module to the core right now. Here
                             for future compatibility. */
    ValkeyModuleKey *key; /* Opened key. */
} ValkeyModuleKeyInfoV1;

#define ValkeyModuleKeyInfo ValkeyModuleKeyInfoV1

#define VALKEYMODULE_AUTHENTICATION_INFO_VERSION 1
typedef struct ValkeyModuleAuthenticationInfo {
    uint64_t version;        /* Version of this structure for ABI compat. */
    uint64_t client_id;      /* Client ID. */
    char addr[46];           /* IPv4 or IPv6 address. */
    uint16_t port;           /* TCP port. */
    const char *username;    /* Username used for authentication. */
    const char *module_name; /* Name of the module that is handling the authentication. */
    int success;             /* Result of the authentication, 1 for success, 0 for failure. */
} ValkeyModuleAuthenticationInfoV1;

#define ValkeyModuleAuthenticationInfo ValkeyModuleAuthenticationInfoV1

#define VALKEYMODULE_AUTHENTICATIONINFO_INITIALIZER_V1 {.version = 1}

typedef enum {
    VALKEYMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */
    VALKEYMODULE_ACL_LOG_CMD,      /* Command authorization failure */
    VALKEYMODULE_ACL_LOG_KEY,      /* Key authorization failure */
    VALKEYMODULE_ACL_LOG_CHANNEL   /* Channel authorization failure */
} ValkeyModuleACLLogEntryReason;

/* Incomplete structures needed by both the core and modules. */
typedef struct ValkeyModuleCtx ValkeyModuleCtx;
typedef struct ValkeyModuleIO ValkeyModuleIO;
typedef struct ValkeyModuleDigest ValkeyModuleDigest;
typedef struct ValkeyModuleInfoCtx ValkeyModuleInfoCtx;
typedef struct ValkeyModuleDefragCtx ValkeyModuleDefragCtx;

/* Function pointers needed by both the core and modules, these needs to be

Review comment (suggestion):
```
    char addr[NET_IP_STR_LEN];   /* IPv4 or IPv6 address. */
```

Code after:
#define VALKEYMODULE_SWAPDBINFO_VERSION 1
typedef struct ValkeyModuleSwapDbInfo {
    uint64_t version;     /* Not used since this structure is never passed
                             from the module to the core right now. Here
                             for future compatibility. */
    int32_t dbnum_first;  /* Swap Db first dbnum */
    int32_t dbnum_second; /* Swap Db second dbnum */
} ValkeyModuleSwapDbInfoV1;

#define ValkeyModuleSwapDbInfo ValkeyModuleSwapDbInfoV1

#define VALKEYMODULE_KEYINFO_VERSION 1
typedef struct ValkeyModuleKeyInfo {
    uint64_t version;     /* Not used since this structure is never passed
                             from the module to the core right now. Here
                             for future compatibility. */
    ValkeyModuleKey *key; /* Opened key. */
} ValkeyModuleKeyInfoV1;

#define ValkeyModuleKeyInfo ValkeyModuleKeyInfoV1

#define VALKEYMODULE_AUTHENTICATION_INFO_VERSION 1

typedef enum {
    VALKEYMODULE_AUTH_RESULT_GRANTED = 0, /* Authentication succeeded. */
    VALKEYMODULE_AUTH_RESULT_DENIED = 1,  /* Authentication failed. */
} ValkeyModuleAuthenticationResult;

typedef struct ValkeyModuleAuthenticationInfo {
    uint64_t version;                        /* Version of this structure for ABI compat. */
    uint64_t client_id;                      /* Client ID. */
    const char *username;                    /* Username used for authentication. */
    const char *module_name;                 /* Name of the module that is handling the authentication. */
    ValkeyModuleAuthenticationResult result; /* Result of the authentication */
} ValkeyModuleAuthenticationInfoV1;

#define ValkeyModuleAuthenticationInfo ValkeyModuleAuthenticationInfoV1

#define VALKEYMODULE_AUTHENTICATIONINFO_INITIALIZER_V1 {.version = 1}

typedef enum {
    VALKEYMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */
    VALKEYMODULE_ACL_LOG_CMD,      /* Command authorization failure */
    VALKEYMODULE_ACL_LOG_KEY,      /* Key authorization failure */
    VALKEYMODULE_ACL_LOG_CHANNEL   /* Channel authorization failure */
} ValkeyModuleACLLogEntryReason;

/* Incomplete structures needed by both the core and modules. */
typedef struct ValkeyModuleCtx ValkeyModuleCtx;
typedef struct ValkeyModuleIO ValkeyModuleIO;
typedef struct ValkeyModuleDigest ValkeyModuleDigest;