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
In a Rails app, when I do an asset:precompile, my initializers are loaded. When I'm setting the RedisRepository, the lib/feature.rb will call a refresh! when set_repository is called:
The problem here is that it will try to access Redis on initialization, but when we're doing asset:precompile, we don't have REDIS environment variables set.
I can work around this in our app doing something like this in my initializer:
begin
Redis.current.ping
Feature.set_repository(Feature::Repository::RedisRepository.new("feature_toggles"))
rescue Redis::CannotConnectError
STDERR.puts "WARN: Could not connect to redis. This is OK in asset:precompile, but not in the live environment"
end
But... I think the better solution would be to not do a forced refresh when the repository is set, but rather do it lazily when any of the Feature methods are called for the first time. Thoughts?
The text was updated successfully, but these errors were encountered:
Thanks for this input - I had not thought about such problems. I think a lazy initialization would be better - I will check if the rest can handle this.
If you're ok with this change, then I can put together a pull request for your review. I'd be happy to take a stab at doing #17 (auto-refresh) along with it.
In a Rails app, when I do an asset:precompile, my initializers are loaded. When I'm setting the RedisRepository, the
lib/feature.rb
will call arefresh!
whenset_repository
is called:https://github.com/mgsnova/feature/blob/master/lib/feature.rb#L41
The problem here is that it will try to access Redis on initialization, but when we're doing asset:precompile, we don't have REDIS environment variables set.
I can work around this in our app doing something like this in my initializer:
But... I think the better solution would be to not do a forced refresh when the repository is set, but rather do it lazily when any of the Feature methods are called for the first time. Thoughts?
The text was updated successfully, but these errors were encountered: