Module: Breakers
- Defined in:
- lib/breakers.rb,
lib/breakers/client.rb,
lib/breakers/outage.rb,
lib/breakers/service.rb,
lib/breakers/version.rb,
lib/breakers/outage_exception.rb,
lib/breakers/uptime_middleware.rb
Overview
Implement the main module for the gem, which includes methods for global configuration
Defined Under Namespace
Classes: Client, Outage, OutageException, Service, UptimeMiddleware
Constant Summary collapse
- VERSION =
'1.0'.freeze
Class Method Summary collapse
-
.client ⇒ Breakers::Client
Return the global client.
-
.client=(client) ⇒ Object
Set the global client for use in the middleware.
-
.disabled=(value) ⇒ Object
Set a flag that can globally disable breakers.
-
.disabled? ⇒ Boolean
Return the status of global disabling.
-
.outage_response ⇒ Hash
Query for the outage response configuration.
-
.outage_response=(opts) ⇒ Object
Configure the middleware’s handling of outages.
-
.redis_prefix ⇒ String
Query for the Redis key prefix.
-
.redis_prefix=(prefix) ⇒ Object
Breakers uses a number of Redis keys to store its data.
Class Method Details
.client ⇒ Breakers::Client
Return the global client
24 25 26 |
# File 'lib/breakers.rb', line 24 def self.client @client end |
.client=(client) ⇒ Object
Set the global client for use in the middleware
17 18 19 |
# File 'lib/breakers.rb', line 17 def self.client=(client) @client = client end |
.disabled=(value) ⇒ Object
Set a flag that can globally disable breakers
31 32 33 |
# File 'lib/breakers.rb', line 31 def self.disabled=(value) @disabled = value end |
.disabled? ⇒ Boolean
Return the status of global disabling
38 39 40 |
# File 'lib/breakers.rb', line 38 def self.disabled? defined?(@disabled) && @disabled == true end |
.outage_response ⇒ Hash
Query for the outage response configuration
72 73 74 |
# File 'lib/breakers.rb', line 72 def self.outage_response @outage_response || { type: :exception } end |
.outage_response=(opts) ⇒ Object
Configure the middleware’s handling of outages. The default is to raise a Breakers::OutageException but you can also request that the response comes back with a configurable status code.
65 66 67 |
# File 'lib/breakers.rb', line 65 def self.outage_response=(opts) @outage_response = { type: :exception }.merge(opts) end |
.redis_prefix ⇒ String
Query for the Redis key prefix
55 56 57 |
# File 'lib/breakers.rb', line 55 def self.redis_prefix @redis_prefix || '' end |
.redis_prefix=(prefix) ⇒ Object
Breakers uses a number of Redis keys to store its data. You can pass an optional prefix here to use for the keys so that they will be namespaced properly. Note that it’s also possible to create the Breakers::Client object with a Redis::Namespace object instead, in which case this is unnecessary.
48 49 50 |
# File 'lib/breakers.rb', line 48 def self.redis_prefix=(prefix) @redis_prefix = prefix end |