You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This does not work in Rails by default because redis_config is an ActiveSupport::OrderedOptions object which responds to call, tricking initialize into thinking that it is not a configuration hash.
Allow to detect hashes responding to `#call`, like
This will enable out of the box compatibility with
`Rails.application.config_for` method and should not break existing
use cases
Closeleandromoreira#152
Allow to detect hashes responding to `#call`, like
`ActiveSupport::OrderedOptions`
This will enable out of the box compatibility with
`Rails.application.config_for` method and should not break existing
use cases
Closeleandromoreira#152
tagliala
added a commit
to tagliala/redlock-rb
that referenced
this issue
Nov 21, 2024
Allow to detect hashes responding to `#call`, like
`ActiveSupport::OrderedOptions`
This will enable out of the box compatibility with
`Rails.application.config_for` method and should not break existing
use cases, because `ConnectionPool` and `RedisClient` do not inherit
from `Hash`
Closeleandromoreira#152
Hello,
I've searched for existing issues, apologies if this is a duplicate
We had some troubles using Redlock in a Rails application because of how the
server
parameter is being detected:redlock-rb/lib/redlock/client.rb
Lines 163 to 173 in f176e57
This does not work in Rails by default because
redis_config
is anActiveSupport::OrderedOptions
object which responds tocall
, trickinginitialize
into thinking that it is not a configuration hash.In fact, by adding
to_h
, everything is fineI wonder if there could be a different approach, something like:
It appears to me that the minimum required Ruby version is 2.5.0 because of the runtime requirement on https://rubygems.org/gems/redis-client/versions/0.14.1
Ruby 2.5.0 defines
key?
on hash: https://docs.ruby-lang.org/en/2.5.0/Hash.html#method-i-key-3FI understand that
is_a?(Hash)
is not the same thing askey?
, but ininitialize_client
,options
is being used like a hash with:#delete
#[]
**
operatorSo I guess that this may be a legit change, unless some other options inherit from Hash, which I hope they aren't
I can submit a PR if you are interested
The text was updated successfully, but these errors were encountered: