-
Notifications
You must be signed in to change notification settings - Fork 687
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
Add new replicate module API to bypass command validation #1357
base: unstable
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,6 +782,11 @@ typedef enum { | |
VALKEYMODULE_ACL_LOG_CHANNEL /* Channel authorization failure */ | ||
} ValkeyModuleACLLogEntryReason; | ||
|
||
typedef enum { | ||
VALKEYMODULE_FLAG_DEFAULT = 0, /* Default behavior */ | ||
VALKEYMODULE_FLAG_SKIP_VALIDATION, /* Skip validation */ | ||
} ValkeyModuleFlag; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I get some suggestions if this naming is too general There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there benefit set the flag as enum, more flags later? Can we just use int skip (0 for non-skip, 1 for skip) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's always complicated to have types like this in the module API. I believe we support backward and forward compatiblity for modules. I mean, a module built with the valkeymodule.h from Valkey 10 can run on Valkey 9 and vice versa. A module can check if some function exists in the current server by checking if the function is NULL, like I think Wen's suggestion with an Internally, we can use an enum or int, but that's doesn't have to be part of the API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
|
||
/* Incomplete structures needed by both the core and modules. */ | ||
typedef struct ValkeyModuleIO ValkeyModuleIO; | ||
typedef struct ValkeyModuleDigest ValkeyModuleDigest; | ||
|
@@ -1092,6 +1097,8 @@ VALKEYMODULE_API int (*ValkeyModule_StringToStreamID)(const ValkeyModuleString * | |
VALKEYMODULE_API void (*ValkeyModule_AutoMemory)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; | ||
VALKEYMODULE_API int (*ValkeyModule_Replicate)(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) | ||
VALKEYMODULE_ATTR; | ||
VALKEYMODULE_API int (*ValkeyModule_ReplicateWithFlag)(ValkeyModuleCtx *ctx, ValkeyModuleFlag flag, const char *cmdname, const char *fmt, ...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ValkeyModuleFlag can be set as int, here we can pass int value; |
||
VALKEYMODULE_ATTR; | ||
VALKEYMODULE_API int (*ValkeyModule_ReplicateVerbatim)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; | ||
VALKEYMODULE_API const char *(*ValkeyModule_CallReplyStringPtr)(ValkeyModuleCallReply *reply, | ||
size_t *len)VALKEYMODULE_ATTR; | ||
|
@@ -1750,6 +1757,7 @@ static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, in | |
VALKEYMODULE_GET_API(StringPtrLen); | ||
VALKEYMODULE_GET_API(AutoMemory); | ||
VALKEYMODULE_GET_API(Replicate); | ||
VALKEYMODULE_GET_API(ReplicateWithFlag); | ||
VALKEYMODULE_GET_API(ReplicateVerbatim); | ||
VALKEYMODULE_GET_API(DeleteKey); | ||
VALKEYMODULE_GET_API(UnlinkKey); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls move this function to just above the VM_Replicate, reference the function zsetInitLexRange. It is a helper function too.