Class: SolidRedis::SentinelConfig
- Inherits:
-
Object
- Object
- SolidRedis::SentinelConfig
- Defined in:
- lib/solid_redis/sentinel_config.rb
Constant Summary collapse
- LOCAL_STATE_KEY =
:solid_redis_sentinel_states- DEFAULT_SENTINEL_PORT =
26_379
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reconnect_attempts ⇒ Object
readonly
Returns the value of attribute reconnect_attempts.
-
#redis_client_options ⇒ Object
readonly
Returns the value of attribute redis_client_options.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#sentinel_client_options ⇒ Object
readonly
Returns the value of attribute sentinel_client_options.
-
#sentinel_endpoints ⇒ Object
readonly
Returns the value of attribute sentinel_endpoints.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(name:, sentinels:, role: :master, sentinel_username: nil, sentinel_password: nil, sentinel_ssl: false, sentinel_ssl_params: nil, **redis_options) ⇒ SentinelConfig
constructor
A new instance of SentinelConfig.
- #inspect ⇒ Object
- #new_client(**options) ⇒ Object
- #new_pool(**options) ⇒ Object
- #new_subscription(**options) ⇒ Object
- #notify(event, *arguments) ⇒ Object
- #path ⇒ Object
- #port ⇒ Object
- #reset ⇒ Object
- #resolve ⇒ Object
- #resolved? ⇒ Boolean
- #sentinel? ⇒ Boolean
- #sentinels ⇒ Object
- #server_key ⇒ Object
- #server_url ⇒ Object
Constructor Details
#initialize(name:, sentinels:, role: :master, sentinel_username: nil, sentinel_password: nil, sentinel_ssl: false, sentinel_ssl_params: nil, **redis_options) ⇒ SentinelConfig
Returns a new instance of SentinelConfig.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solid_redis/sentinel_config.rb', line 11 def initialize( name:, sentinels:, role: :master, sentinel_username: nil, sentinel_password: nil, sentinel_ssl: false, sentinel_ssl_params: nil, ** ) @name = String(name).dup.freeze @role = normalize_role(role) endpoints = sentinels.map { |endpoint| normalize_endpoint(endpoint) } @sentinel_endpoints = Shareable.copy(endpoints, label: "sentinels") raise ArgumentError, "At least one Sentinel endpoint is required" if @sentinel_endpoints.empty? @reconnect_attempts = Integer(.fetch(:reconnect_attempts, 2)) raise ArgumentError, "reconnect_attempts must not be negative" if @reconnect_attempts.negative? = Shareable.copy(, label: "Redis options") = Shareable.copy( ( , username: sentinel_username, password: sentinel_password, ssl: sentinel_ssl, ssl_params: sentinel_ssl_params, ), label: "Sentinel options", ) Ractor.make_shareable(self) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def name @name end |
#reconnect_attempts ⇒ Object (readonly)
Returns the value of attribute reconnect_attempts.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def reconnect_attempts @reconnect_attempts end |
#redis_client_options ⇒ Object (readonly)
Returns the value of attribute redis_client_options.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def role @role end |
#sentinel_client_options ⇒ Object (readonly)
Returns the value of attribute sentinel_client_options.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def end |
#sentinel_endpoints ⇒ Object (readonly)
Returns the value of attribute sentinel_endpoints.
8 9 10 |
# File 'lib/solid_redis/sentinel_config.rb', line 8 def sentinel_endpoints @sentinel_endpoints end |
Instance Method Details
#host ⇒ Object
61 62 63 |
# File 'lib/solid_redis/sentinel_config.rb', line 61 def host resolve.host end |
#inspect ⇒ Object
104 105 106 |
# File 'lib/solid_redis/sentinel_config.rb', line 104 def inspect "#<#{self.class.name} name=#{name.inspect} role=#{role.inspect} sentinels=#{sentinel_endpoints.length}>" end |
#new_client(**options) ⇒ Object
85 86 87 |
# File 'lib/solid_redis/sentinel_config.rb', line 85 def new_client(**) Client.new(self, **) end |
#new_pool(**options) ⇒ Object
89 90 91 |
# File 'lib/solid_redis/sentinel_config.rb', line 89 def new_pool(**) Pool.new(self, **) end |
#new_subscription(**options) ⇒ Object
93 94 95 |
# File 'lib/solid_redis/sentinel_config.rb', line 93 def new_subscription(**) Subscription.new(self, **) end |
#notify(event, *arguments) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/solid_redis/sentinel_config.rb', line 97 def notify(event, *arguments) callbacks = [:callbacks] return unless callbacks&.respond_to?(event) callbacks.respond_with(event, *arguments) end |
#path ⇒ Object
69 70 71 |
# File 'lib/solid_redis/sentinel_config.rb', line 69 def path nil end |
#port ⇒ Object
65 66 67 |
# File 'lib/solid_redis/sentinel_config.rb', line 65 def port resolve.port end |
#reset ⇒ Object
56 57 58 59 |
# File 'lib/solid_redis/sentinel_config.rb', line 56 def reset state.reset self end |
#resolve ⇒ Object
52 53 54 |
# File 'lib/solid_redis/sentinel_config.rb', line 52 def resolve state.resolve end |
#resolved? ⇒ Boolean
48 49 50 |
# File 'lib/solid_redis/sentinel_config.rb', line 48 def resolved? state.resolved? end |
#sentinel? ⇒ Boolean
44 45 46 |
# File 'lib/solid_redis/sentinel_config.rb', line 44 def sentinel? true end |
#sentinels ⇒ Object
81 82 83 |
# File 'lib/solid_redis/sentinel_config.rb', line 81 def sentinels state.sentinel_endpoints end |
#server_key ⇒ Object
73 74 75 |
# File 'lib/solid_redis/sentinel_config.rb', line 73 def server_key resolve.server_key end |
#server_url ⇒ Object
77 78 79 |
# File 'lib/solid_redis/sentinel_config.rb', line 77 def server_url resolve.server_url end |