-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add support for MODULE LOADEX command #2490
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a20aa56
Added support for MODULE LOADEX command
ktsivkov 42d1642
Merge branch 'master' into loadex-support
ktsivkov 40f7e59
Merge branch 'master' into loadex-support
ktsivkov ba82e63
Merge branch 'master' into loadex-support
ktsivkov efb3425
Export the Loadex command through the available interface
ktsivkov ba59a11
Add tests for redis module loadex, and enable `--enable-module-comman…
ktsivkov 973f0fe
Removed module_loadex files, and moved their code inside commands'
ktsivkov 5ed499c
Merge branch 'master' into loadex-support
ktsivkov 2da69f2
Allocate the correct amount of memory
ktsivkov 4f0ee02
Merge branch 'master' into loadex-support
ktsivkov a24221f
Merge pull request #1 from redis/master
ktsivkov 9b60cc8
Renamed ModuleLoadexConfig ToArgs to toArgs and export it for tests only
ktsivkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
package redis | ||
|
||
// ModuleLoadexConfig struct is used to specify the arguments for the MODULE LOADEX command of redis. | ||
// `MODULE LOADEX path [CONFIG name value [CONFIG name value ...]] [ARGS args [args ...]]` | ||
type ModuleLoadexConfig struct { | ||
Path string | ||
Conf map[string]interface{} | ||
Args []interface{} | ||
} | ||
|
||
func (c *ModuleLoadexConfig) ToArgs() []interface{} { | ||
var args = make([]interface{}, 3, len(c.Conf)*2+len(c.Args)+3) | ||
args[0] = "MODULE" | ||
args[1] = "LOADEX" | ||
args[2] = c.Path | ||
for k, v := range c.Conf { | ||
args = append(args, "CONFIG", k, v) | ||
} | ||
for _, arg := range c.Args { | ||
args = append(args, "ARGS", arg) | ||
} | ||
return args | ||
} |
This file contains hidden or 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,52 @@ | ||
package redis_test | ||
|
||
import ( | ||
. "github.com/bsm/ginkgo/v2" | ||
. "github.com/bsm/gomega" | ||
|
||
"github.com/redis/go-redis/v9" | ||
) | ||
|
||
var _ = Describe("Loadex Config", func() { | ||
It("converts the configuration to a slice of arguments correctly", func() { | ||
conf := &redis.ModuleLoadexConfig{ | ||
Path: "/path/to/your/module.so", | ||
Conf: map[string]interface{}{ | ||
"param1": "value1", | ||
"param2": "value2", | ||
"param3": 3, | ||
}, | ||
Args: []interface{}{ | ||
"arg1", | ||
"arg2", | ||
3, | ||
}, | ||
} | ||
|
||
args := conf.ToArgs() | ||
|
||
// Test if the arguments are in the correct order | ||
expectedArgs := []interface{}{ | ||
"MODULE", | ||
"LOADEX", | ||
"/path/to/your/module.so", | ||
"CONFIG", | ||
"param1", | ||
"value1", | ||
"CONFIG", | ||
"param2", | ||
"value2", | ||
"CONFIG", | ||
"param3", | ||
3, | ||
"ARGS", | ||
"arg1", | ||
"ARGS", | ||
"arg2", | ||
"ARGS", | ||
3, | ||
} | ||
|
||
Expect(args).To(Equal(expectedArgs)) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.