Class: Faulty::Storage::Redis::Options

Inherits:
Struct
  • Object
show all
Includes:
ImmutableOptions
Defined in:
lib/faulty/storage/redis.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ImmutableOptions

#dup_with, #initialize, #setup

Instance Attribute Details

#circuit_ttlInteger (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).

Returns:

  • (Integer)

    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

#clientRedis, ConnectionPool (readonly)

Returns The Redis instance or a ConnectionPool used to connect to Redis. Default ::Redis.new.

Returns:

  • (Redis, ConnectionPool)

    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_warningsBoolean (readonly)

Returns By default, this class warns if the client options are outside the recommended values. Set to true to disable these warnings.

Returns:

  • (Boolean)

    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_prefixString (readonly)

Returns A string prepended to all Redis keys used to store circuit state. Default faulty.

Returns:

  • (String)

    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_separatorString (readonly)

Returns A string used to separate the parts of the Redis keys used to store circuit state. Default :.

Returns:

  • (String)

    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_granularityInteger (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).

Returns:

  • (Integer)

    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_sizeInteger (readonly)

Returns The number of cache run entries to keep in memory for each circuit. Default 100.

Returns:

  • (Integer)

    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_ttlInteger (readonly)

Returns The maximum number of seconds to store a circuit run history entry. Default 100.

Returns:

  • (Integer)

    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

#defaultsObject



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

#finalizeObject



76
77
78
# File 'lib/faulty/storage/redis.rb', line 76

def finalize
  self.client = ::Redis.new(timeout: 1) unless client
end

#requiredObject



72
73
74
# File 'lib/faulty/storage/redis.rb', line 72

def required
  %i[list_granularity]
end