-
Notifications
You must be signed in to change notification settings - Fork 66
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
Allow the crate to operate when the Redis API isn't available. #300
Allow the crate to operate when the Redis API isn't available. #300
Conversation
Without these changes, it is currently impossible for any other crate depending on this one (redismodule-rs) to run tests and work without Redis. |
Such situations occur when, for example, the crate which uses the redismodule-rs crate as a dependency is run for testing, so without Redis available. In this case, there is no allocator available as well and it will lead to a panic. To enable both the situations to work correctly under all circumstances, this change introduces a fallback mechanism back to the system allocator (default Rust allocator) which is always available. Note that the changes are zero-cost: the code before this changes used unwrap() which also had checks for the value being non-null and would panic at runtime if it was null, the current code does this check as well but instead of panicking reverts back to the system allocator.
cc46c7e
to
cf0473c
Compare
4242cf6
to
f873f8a
Compare
Also fixes: #89 |
The previous code either wouldn't compile or wouldn't run due to missing assets for the tests. This commit brings changes necessary to enable the cargo test to run properly again.
I also highly recommend running the |
0c58923
to
90770dc
Compare
Reverts the behaviour to panicking when the redis allocator isn't present. Changes the panic to avoid allocations using the specified allocator so that a meaningful message can be observed.
90770dc
to
03b52b9
Compare
@vityafx @oshadmi this pr is made for api_extantions branch. We are gone drop this branch soon as all the changes was added to master. For progress lets merge this and make sure to take the relevant changes to master on another PR. |
@vityafx @gkorland I get |
Hey @BruAPAHE , look how we solve it on RedisGears: https://github.com/RedisGears/RedisGears/blob/c6de5d50eb92ecbdfc976fb5b15bd6beb9d44c12/redisgears_core/src/lib.rs#L1256 |
@MeirShpilraien Thank you so much!!! |
Such situations occur when, for example, the crate which uses the redismodule-rs crate as a dependency is run for testing, so without Redis available. In this case, there is no allocator available as well, and it will lead to panic. To enable both situations to work correctly under all circumstances, this change introduces a fallback mechanism back to the system allocator (default Rust allocator), which is always available.
Note that the changes are zero-cost: the code before these changes used unwrap(), which also had checks for the value being non-null and would panic at runtime if it was null; the current code does this check as well, but instead of panicking reverts back to the system allocator.