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, #connection_prelude, #custom, #db, #driver, #id, #inherit_socket, #middlewares_stack, #password, #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
#new_client, #new_pool, #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.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/redis_client/config.rb', line 175 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.
173 174 175 |
# File 'lib/redis_client/config.rb', line 173 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
173 174 175 |
# File 'lib/redis_client/config.rb', line 173 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
173 174 175 |
# File 'lib/redis_client/config.rb', line 173 def port @port end |