Class: RedisClient::Config

Inherits:
Object
  • Object
show all
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

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

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.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/redis_client/config.rb', line 162

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
    username ||= url_config.username
    password ||= url_config.password
  end

  super(username: username, password: password, **kwargs)

  @host = host || DEFAULT_HOST
  @port = Integer(port || DEFAULT_PORT)
  @path = path
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



160
161
162
# File 'lib/redis_client/config.rb', line 160

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



160
161
162
# File 'lib/redis_client/config.rb', line 160

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



160
161
162
# File 'lib/redis_client/config.rb', line 160

def port
  @port
end