Class: Faulty::Storage::Redis::Options
- Inherits:
-
Struct
- Object
- Struct
- Faulty::Storage::Redis::Options
- Includes:
- ImmutableOptions
- Defined in:
- lib/faulty/storage/redis.rb
Overview
Options for Faulty::Storage::Redis
Instance Attribute Summary collapse
-
#circuit_ttl ⇒ Integer
readonly
The maximum number of seconds to keep a circuit.
-
#client ⇒ Redis, ConnectionPool
readonly
The Redis instance or a ConnectionPool used to connect to Redis.
-
#disable_warnings ⇒ Boolean
readonly
By default, this class warns if the client options are outside the recommended values.
-
#key_prefix ⇒ String
readonly
A string prepended to all Redis keys used to store circuit state.
-
#key_separator ⇒ String
readonly
A string used to separate the parts of the Redis keys used to store circuit state.
-
#list_granularity ⇒ Integer
readonly
The number of seconds after which a new set is created to store circuit names.
-
#max_sample_size ⇒ Integer
readonly
The number of cache run entries to keep in memory for each circuit.
-
#sample_ttl ⇒ Integer
readonly
The maximum number of seconds to store a circuit run history entry.
Instance Method Summary collapse
Methods included from ImmutableOptions
#dup_with, #initialize, #setup
Instance Attribute Details
#circuit_ttl ⇒ Integer (readonly)
Returns The maximum number of seconds to keep a circuit.
A value of nil
disables circuit expiration. This does not apply to
locks, which have an indefinite storage time.
Default 604_800
(1 week).
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#client ⇒ Redis, ConnectionPool (readonly)
Returns The Redis instance or a ConnectionPool
used to connect to Redis. Default ::Redis.new
.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#disable_warnings ⇒ Boolean (readonly)
Returns By default, this class warns if the client options are outside the recommended values. Set to true to disable these warnings.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#key_prefix ⇒ String (readonly)
Returns A string prepended to all Redis keys used to store
circuit state. Default faulty
.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#key_separator ⇒ String (readonly)
Returns A string used to separate the parts of the Redis keys
used to store circuit state. Default :
.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#list_granularity ⇒ Integer (readonly)
Returns The number of seconds after which a new set is
created to store circuit names. The old set is kept until
circuit_ttl expires. Default 3600
(1 hour).
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#max_sample_size ⇒ Integer (readonly)
Returns The number of cache run entries to keep in memory
for each circuit. Default 100
.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
#sample_ttl ⇒ Integer (readonly)
Returns The maximum number of seconds to store a
circuit run history entry. Default 100
.
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 |
# File 'lib/faulty/storage/redis.rb', line 48 Options = Struct.new( :client, :key_prefix, :key_separator, :max_sample_size, :sample_ttl, :circuit_ttl, :list_granularity, :disable_warnings ) do include ImmutableOptions def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end def required %i[list_granularity] end def finalize self.client = ::Redis.new(timeout: 1) unless client end end |
Instance Method Details
#defaults ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/faulty/storage/redis.rb', line 60 def defaults { key_prefix: 'faulty', key_separator: ':', max_sample_size: 100, sample_ttl: 1800, circuit_ttl: 604_800, list_granularity: 3600, disable_warnings: false } end |
#finalize ⇒ Object
76 77 78 |
# File 'lib/faulty/storage/redis.rb', line 76 def finalize self.client = ::Redis.new(timeout: 1) unless client end |
#required ⇒ Object
72 73 74 |
# File 'lib/faulty/storage/redis.rb', line 72 def required %i[list_granularity] end |