Class: RedisClient::Config
- Includes:
- Common
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/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, **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, **kwargs) ⇒ Config
Returns a new instance of Config.
155 156 157 158 159 160 161 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 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 155 def initialize( url: nil, host: nil, port: nil, path: nil, **kwargs ) if url uri = URI(url) unless uri.scheme == "redis" || uri.scheme == "rediss" raise ArgumentError, "Invalid URL: #{url.inspect}" end kwargs[:ssl] = uri.scheme == "rediss" unless kwargs.key?(:ssl) kwargs[:username] ||= uri.user if uri.password && !uri.user.empty? kwargs[:password] ||= if uri.user && !uri.password URI.decode_www_form_component(uri.user) elsif uri.user && uri.password URI.decode_www_form_component(uri.password) end db_path = uri.path&.delete_prefix("/") kwargs[:db] ||= Integer(db_path) if db_path && !db_path.empty? end super(**kwargs) @host = host || uri&.host&.sub(/\A\[(.*)\]\z/, '\1') || DEFAULT_HOST @port = Integer(port || uri&.port || DEFAULT_PORT) @path = path end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
153 154 155 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 153 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
153 154 155 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 153 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
153 154 155 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 153 def port @port end |