lib/redis_failover/util.rb in redis_failover-0.4.0 vs lib/redis_failover/util.rb in redis_failover-0.5.0
- old
+ new
@@ -1,10 +1,20 @@
+require 'redis_failover/errors'
+
module RedisFailover
# Common utiilty methods.
module Util
extend self
+ DEFAULT_ZNODE_PATH = '/redis_failover_nodes'
+ REDIS_ERRORS = Errno.constants.map { |c| Errno.const_get(c) }
+ ALL_ERRORS = [
+ RedisFailover::Error,
+ ZookeeperExceptions::ZookeeperException,
+ REDIS_ERRORS,
+ StandardError].flatten
+
def symbolize_keys(hash)
Hash[hash.map { |k, v| [k.to_sym, v] }]
end
def different?(ary_a, ary_b)
@@ -26,8 +36,17 @@
@logger = logger
end
def logger
Util.logger
+ end
+
+ def encode(data)
+ MultiJson.encode(data)
+ end
+
+ def decode(data)
+ return unless data
+ MultiJson.decode(data)
end
end
end