forked from valkey-io/valkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example to indicate how to use admin port
Signed-off-by: hwware <[email protected]>
- Loading branch information
Showing
7 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "valkeymodule.h" | ||
|
||
#include <string.h> | ||
|
||
int testadminport_runspecificcommand(ValkeyModuleCtx *ctx, | ||
ValkeyModuleString **argv, int argc) { | ||
VALKEYMODULE_NOT_USED(argv); | ||
VALKEYMODULE_NOT_USED(argc); | ||
int port = ValkeyModule_GetClientConnectedPort(ctx); | ||
if (port == 7001) { | ||
ValkeyModule_ReplyWithSimpleString(ctx, "You can execute this command"); | ||
} else { | ||
ValkeyModule_ReplyWithSimpleString( | ||
ctx, "You have no permission to execute this command"); | ||
} | ||
return VALKEYMODULE_OK; | ||
} | ||
|
||
int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, | ||
int argc) { | ||
VALKEYMODULE_NOT_USED(argv); | ||
VALKEYMODULE_NOT_USED(argc); | ||
if (ValkeyModule_Init(ctx, "adminport", 1, VALKEYMODULE_APIVER_1) == | ||
VALKEYMODULE_ERR) | ||
return VALKEYMODULE_ERR; | ||
|
||
if (ValkeyModule_CreateCommand(ctx, "testadminport.runspecificcommand", | ||
testadminport_runspecificcommand, "", 0, 0, | ||
0) == VALKEYMODULE_ERR) | ||
return VALKEYMODULE_ERR; | ||
|
||
return VALKEYMODULE_OK; | ||
} |