1
0
mirror of https://github.com/redis/go-redis.git synced 2025-11-30 18:01:23 +03:00
Commit Graph

6 Commits

Author SHA1 Message Date
ofekshenawa
f711eb0f62 feat(cluster): Implement Request and Response Policy Based Routing in Cluster Mode (#3422)
* Add search module builders and tests (#1)

* Add search module builders and tests

* Add tests

* Use builders and Actions in more clean way

* Update search_builders.go

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* Update search_builders.go

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* feat(routing): add internal request/response policy enums

* feat: load the policy table in cluster client (#4)

* feat: load the policy table in cluster client

* Remove comments

* modify Tips and command pplicy in commandInfo (#5)

* centralize cluster command routing in osscluster_router.go and refactor osscluster.go (#6)

* centralize cluster command routing in osscluster_router.go and refactor osscluster.go

* enalbe ci on all branches

* Add debug prints

* Add debug prints

* FIX: deal with nil policy

* FIX: fixing clusterClient process

* chore(osscluster): simplify switch case

* wip(command): ai generated clone method for commands

* feat: implement response aggregator for Redis cluster commands

* feat: implement response aggregator for Redis cluster commands

* fix: solve concurrency errors

* fix: solve concurrency errors

* return MaxRedirects settings

* remove locks from getCommandPolicy

* Handle MOVED errors more robustly, remove cluster reloading at exectutions, ennsure better routing

* Fix: supports Process hook test

* Fix: remove response aggregation for single shard commands

* Add more preformant type conversion for Cmd type

* Add router logic into processPipeline

---------

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>

* remove thread debugging code

* remove thread debugging code && reject commands with policy that cannot be used in pipeline

* refactor processPipline and cmdType enum

* remove FDescribe from cluster tests

* Add tests

* fix aggregation test

* fix mget test

* fix mget test

* remove aggregateKeyedResponses

* added scaffolding for the req-resp manager

* added default policies for the search commands

* split command map into module->command

* cleanup, added logic to refresh the cache

* added reactive cache refresh

* revert cluster refresh

* fixed lint

* addresed first batch of comments

* rewrote aggregator implementations with atomic for native or nearnative primitives

* addressed more comments, fixed lint

* added batch aggregator operations

* fixed lint

* updated batch aggregator, fixed extractcommandvalue

* fixed lint

* added batching to aggregateResponses

* fixed deadlocks

* changed aggregator logic, added error params

* added preemptive return to the aggregators

* more work on the aggregators

* updated and and or aggregators

* fixed lint

* added configurable policy resolvers

* slight refactor

* removed the interface, slight refactor

* change func signature from cmdName to cmder

* added nil safety assertions

* few small refactors

* added read only policies

* removed leftover prints

* Rebased to master, resolved comnflicts

* fixed lint

* updated gha

* fixed tests, minor consistency refactor

* preallocated simple errors

* changed numeric aggregators to use float64

* speculative test fix

* Update command.go

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* Update main_test.go

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* Add static shard picker

* Fix nil value handling in command aggregation

* Modify the Clone method to return a shallow copy

* Add clone method to digest command

* Optimize keyless command routing to respect ShardPicker policy

* Remove MGET references

* Fix MGET aggregation to map individual values to keys across shards

* Add clone method to hybrid search commands

* Undo changes in route keyless test

* remove comments

* Add test for DisableRoutingPolicies option

* Add Routing Policies Comprehensive Test Suite and Fix multi keyed aggregation for different step

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
Co-authored-by: Hristo Temelski <hristo.temelski@redis.com>
2025-11-28 11:46:23 +02:00
ofekshenawa
0b1e9f77ef fix(json): Ensure that JSON.GET returns Nil response (#3470)
* fix conflicts

* Fix JSON nil response handling

Ensure that JSON.GET returns redis.Nil for missing keys/paths,
making it consistent with other Redis commands.

- Restore proper nil detection logic in JSONCmd.readReply
- Add comprehensive test coverage for JSON nil scenarios
- Handle both non-existent keys and non-existent paths consistently
- Distinguish between empty arrays and nil responses
- Add documentation for Val() and Expanded() methods

Original work and problem identification by Nic Gibson.
Enhanced implementation with comprehensive testing and fixes
for the broken nil detection logic.

Fixes #2987

* Fix JSON nil response handling - align with Redis behavior

- Non-existent keys return redis.Nil (consistent with other Redis commands)
- Non-existent paths in existing keys return empty array '[]'
- Fix broken test that was using wrong doc1 reference
- Add comprehensive test coverage for JSON nil scenarios

This aligns with official Redis JSON.GET behavior:
- Missing keys should return nil error like other Redis commands
- Missing paths should return empty JSON array, not error

* Fix JSONDel tests

---------

Co-authored-by: Nic Gibson <nic.gibson@redis.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-08-12 14:28:07 +03:00
ofekshenawa
2076975008 Support Json with Resp 2 (#3146)
* Support ReJSON resp 2 && Test ReJSON against RESP 2 and 3 && Add complex search and json test

* Remove comments

* Remove unnecessary changes
2024-10-14 14:37:22 +03:00
dragon-fly
d8e3e95866 return raw value instead of funcation calling in Result() (#2831)
Signed-off-by: lowang-bh <lhui_wang@163.com>
2024-01-03 10:43:42 +02:00
Ilia Kuznetcov
c828764336 Allow scanning redis values into pointer fields (#2787)
* Allow scanning redis values into pointer fields

* Formatting

---------

Co-authored-by: Ilia Personal <iliapersonal@Ilyas-MBP.station>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-12-17 17:42:45 +02:00
ofekshenawa
0d7a013e5d Json support (#2769)
* Add support for RedisJSON

* Add optional args and tests

* Add more tests

* Add more tests

* Add more tests and cleanups

* Add docstring

* update JSONArrIndex and matching texts

Rename JSONArrIndexWithArgs to JSONArrIndexArgs
change name of args struct to match function name for consistency
change arg types to int (for required arg) and *int (for optional)

* update JSONArrTrim and matching texts

Rename JSONArrTrimWithArgs to JSONArrTrimArgs
change name of args struct to match function name for consistency
change arg types to int (for required arg) and *int (for optional)

* update JSONGetWithArgs and matching texts

Rename JSONGetWithArgs to JSONGetArgs
Removed Paths & Path from args - redundant and ambiguous
Renamed mispelled "Indention"
Changed args param from pointer to value
Updated and added additional tests for formatting params

* Update JSONSetMode

changed mode parameter back to string, added value checking for that
string

* Updated JSONMSet

Changed name of param struct to ...Args  for consistency
Updated arg list to use an array of structs not pointers as
all args are mandatory (we never want to pass a nil parameter)

* Updated tests for JSONMSet

* Added stubbed (panicking) implementations of JSON.RESP AND JSON.DEBUG

* Pre-pull request tidy up

Renamed xArgs() to xWithArgs to match other Redis modules

Modified params to xWithArgs functions to use a pointer for the
arguments struct to match other Redis modules.

Modified JSONMSet to JSONMSetArgs and added a version that takes
a vararray of args to match the semantics of the native redis call

Updated tests to match above changes.

Renamed some variables in the json tests for consistency

* Testing fixes

Fixed error in JSONSetWithArgs found during tests
Fixed tests for indentation

* fix JSONCmdable typo (#5)

* Remove deprecated command: JSONNumMultBy (#6)

* Lowercase newJSONCmd (#7)

---------

Co-authored-by: Nic Gibson <nic.gibson@redis.com>
Co-authored-by: Nic Gibson <newt+github@noslogan.org>
2023-10-30 14:09:25 +02:00