Module: RedisClient::Config::Common
- Included in:
- RedisClient::Config, SentinelConfig
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb
Instance Attribute Summary collapse
-
#circuit_breaker ⇒ Object
readonly
Returns the value of attribute circuit_breaker.
-
#command_builder ⇒ Object
readonly
Returns the value of attribute command_builder.
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#connection_prelude ⇒ Object
readonly
Returns the value of attribute connection_prelude.
-
#custom ⇒ Object
readonly
Returns the value of attribute custom.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inherit_socket ⇒ Object
readonly
Returns the value of attribute inherit_socket.
-
#middlewares_stack ⇒ Object
readonly
Returns the value of attribute middlewares_stack.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#ssl ⇒ Object
(also: #ssl?)
readonly
Returns the value of attribute ssl.
-
#ssl_params ⇒ Object
readonly
Returns the value of attribute ssl_params.
-
#write_timeout ⇒ Object
readonly
Returns the value of attribute write_timeout.
Instance Method Summary collapse
- #initialize(username: nil, password: nil, db: nil, id: nil, timeout: DEFAULT_TIMEOUT, read_timeout: timeout, write_timeout: timeout, connect_timeout: timeout, ssl: nil, custom: {}, ssl_params: nil, driver: nil, protocol: 3, client_implementation: RedisClient, command_builder: CommandBuilder, inherit_socket: false, reconnect_attempts: false, middlewares: false, circuit_breaker: nil) ⇒ Object
- #new_client(**kwargs) ⇒ Object
- #new_pool(**kwargs) ⇒ Object
- #retry_connecting?(attempt, _error) ⇒ Boolean
- #sentinel? ⇒ Boolean
- #server_url ⇒ Object
- #ssl_context ⇒ Object
- #username ⇒ Object
Instance Attribute Details
#circuit_breaker ⇒ Object (readonly)
Returns the value of attribute circuit_breaker.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def circuit_breaker @circuit_breaker end |
#command_builder ⇒ Object (readonly)
Returns the value of attribute command_builder.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def command_builder @command_builder end |
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def connect_timeout @connect_timeout end |
#connection_prelude ⇒ Object (readonly)
Returns the value of attribute connection_prelude.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def connection_prelude @connection_prelude end |
#custom ⇒ Object (readonly)
Returns the value of attribute custom.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def custom @custom end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def db @db end |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def driver @driver end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def id @id end |
#inherit_socket ⇒ Object (readonly)
Returns the value of attribute inherit_socket.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def inherit_socket @inherit_socket end |
#middlewares_stack ⇒ Object (readonly)
Returns the value of attribute middlewares_stack.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def middlewares_stack @middlewares_stack end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def password @password end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def protocol @protocol end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def read_timeout @read_timeout end |
#ssl ⇒ Object (readonly) Also known as: ssl?
Returns the value of attribute ssl.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def ssl @ssl end |
#ssl_params ⇒ Object (readonly)
Returns the value of attribute ssl_params.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def ssl_params @ssl_params end |
#write_timeout ⇒ Object (readonly)
Returns the value of attribute write_timeout.
15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 15 def write_timeout @write_timeout end |
Instance Method Details
#initialize(username: nil, password: nil, db: nil, id: nil, timeout: DEFAULT_TIMEOUT, read_timeout: timeout, write_timeout: timeout, connect_timeout: timeout, ssl: nil, custom: {}, ssl_params: nil, driver: nil, protocol: 3, client_implementation: RedisClient, command_builder: CommandBuilder, inherit_socket: false, reconnect_attempts: false, middlewares: false, circuit_breaker: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 21 def initialize( username: nil, password: nil, db: nil, id: nil, timeout: DEFAULT_TIMEOUT, read_timeout: timeout, write_timeout: timeout, connect_timeout: timeout, ssl: nil, custom: {}, ssl_params: nil, driver: nil, protocol: 3, client_implementation: RedisClient, command_builder: CommandBuilder, inherit_socket: false, reconnect_attempts: false, middlewares: false, circuit_breaker: nil ) @username = username @password = password @db = db || DEFAULT_DB @id = id @ssl = ssl || false @ssl_params = ssl_params @connect_timeout = connect_timeout @read_timeout = read_timeout @write_timeout = write_timeout @driver = driver ? RedisClient.driver(driver) : RedisClient.default_driver @custom = custom @client_implementation = client_implementation @protocol = protocol unless protocol == 2 || protocol == 3 raise ArgumentError, "Unknown protocol version #{protocol.inspect}, expected 2 or 3" end @command_builder = command_builder @inherit_socket = inherit_socket reconnect_attempts = Array.new(reconnect_attempts, 0).freeze if reconnect_attempts.is_a?(Integer) @reconnect_attempts = reconnect_attempts @connection_prelude = build_connection_prelude circuit_breaker = CircuitBreaker.new(**circuit_breaker) if circuit_breaker.is_a?(Hash) if @circuit_breaker = circuit_breaker middlewares = [CircuitBreaker::Middleware] + (middlewares || []) end middlewares_stack = Middlewares if middlewares && !middlewares.empty? middlewares_stack = Class.new(Middlewares) middlewares.each do |mod| middlewares_stack.include(mod) end end @middlewares_stack = middlewares_stack end |
#new_client(**kwargs) ⇒ Object
98 99 100 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 98 def new_client(**kwargs) @client_implementation.new(self, **kwargs) end |
#new_pool(**kwargs) ⇒ Object
93 94 95 96 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 93 def new_pool(**kwargs) kwargs[:timeout] ||= DEFAULT_TIMEOUT Pooled.new(self, **kwargs) end |
#retry_connecting?(attempt, _error) ⇒ Boolean
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 102 def retry_connecting?(attempt, _error) if @reconnect_attempts if (pause = @reconnect_attempts[attempt]) if pause > 0 sleep(pause) end return true end end false end |
#sentinel? ⇒ Boolean
89 90 91 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 89 def sentinel? false end |
#server_url ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 118 def server_url if path "#{path}/#{db}" else "redis#{'s' if ssl?}://#{host}:#{port}/#{db}" end end |
#ssl_context ⇒ Object
114 115 116 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 114 def ssl_context @ssl_context ||= @driver.ssl_context(@ssl_params || {}) end |
#username ⇒ Object
85 86 87 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/config.rb', line 85 def username @username || DEFAULT_USERNAME end |