Class: RedisClient::Config
- Inherits:
-
Object
- Object
- RedisClient::Config
- Includes:
- Common
- Defined in:
- lib/redis_client/config.rb
Defined Under Namespace
Modules: Common
Constant Summary collapse
- DEFAULT_TIMEOUT =
1.0
- DEFAULT_HOST =
"localhost"
- DEFAULT_PORT =
6379
- DEFAULT_USERNAME =
"default"
- DEFAULT_DB =
0
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Attributes included from Common
#circuit_breaker, #command_builder, #connect_timeout, #custom, #db, #driver, #id, #inherit_socket, #middlewares_stack, #protocol, #read_timeout, #ssl, #ssl_params, #write_timeout
Instance Method Summary collapse
-
#initialize(url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, **kwargs) ⇒ Config
constructor
A new instance of Config.
Methods included from Common
#connection_prelude, #new_client, #new_pool, #password, #resolved?, #retry_connecting?, #sentinel?, #server_url, #ssl_context, #username
Constructor Details
#initialize(url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, **kwargs) ⇒ Config
Returns a new instance of Config.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/redis_client/config.rb', line 202 def initialize( url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, **kwargs ) if url url_config = URLConfig.new(url) kwargs = { ssl: url_config.ssl?, db: url_config.db, }.compact.merge(kwargs) host ||= url_config.host port ||= url_config.port path ||= url_config.path username ||= url_config.username password ||= url_config.password end super(username: username, password: password, **kwargs) if @path = path @host = nil @port = nil else @host = host || DEFAULT_HOST @port = Integer(port || DEFAULT_PORT) end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
200 201 202 |
# File 'lib/redis_client/config.rb', line 200 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
200 201 202 |
# File 'lib/redis_client/config.rb', line 200 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
200 201 202 |
# File 'lib/redis_client/config.rb', line 200 def port @port end |