Class: Semian::ProtectedResource
- Inherits:
-
Object
- Object
- Semian::ProtectedResource
- Extended by:
- Forwardable
- Defined in:
- lib/semian/protected_resource.rb
Instance Attribute Summary collapse
-
#bulkhead ⇒ Object
readonly
Returns the value of attribute bulkhead.
-
#circuit_breaker ⇒ Object
readonly
Returns the value of attribute circuit_breaker.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #acquire(timeout: nil, scope: nil, adapter: nil) ⇒ Object
- #destroy ⇒ Object
-
#initialize(name, bulkhead, circuit_breaker) ⇒ ProtectedResource
constructor
A new instance of ProtectedResource.
Constructor Details
#initialize(name, bulkhead, circuit_breaker) ⇒ ProtectedResource
Returns a new instance of ProtectedResource.
11 12 13 14 15 |
# File 'lib/semian/protected_resource.rb', line 11 def initialize(name, bulkhead, circuit_breaker) @name = name @bulkhead = bulkhead @circuit_breaker = circuit_breaker end |
Instance Attribute Details
#bulkhead ⇒ Object (readonly)
Returns the value of attribute bulkhead.
9 10 11 |
# File 'lib/semian/protected_resource.rb', line 9 def bulkhead @bulkhead end |
#circuit_breaker ⇒ Object (readonly)
Returns the value of attribute circuit_breaker.
9 10 11 |
# File 'lib/semian/protected_resource.rb', line 9 def circuit_breaker @circuit_breaker end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/semian/protected_resource.rb', line 9 def name @name end |
Instance Method Details
#acquire(timeout: nil, scope: nil, adapter: nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/semian/protected_resource.rb', line 22 def acquire(timeout: nil, scope: nil, adapter: nil) acquire_circuit_breaker(scope, adapter) do acquire_bulkhead(timeout, scope, adapter) do yield self end end end |
#destroy ⇒ Object
17 18 19 20 |
# File 'lib/semian/protected_resource.rb', line 17 def destroy @bulkhead.destroy unless @bulkhead.nil? @circuit_breaker.destroy unless @circuit_breaker.nil? end |