Class: Phronomy::Runtime::GateRegistry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/runtime/gate_registry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Lazy cache of ConcurrencyGate instances, keyed by resource name.

Gate concurrency caps are read from Configuration when a gate is first accessed; subsequent calls return the cached instance. Call #reset to drop the cache and force a rebuild on the next access.

Instance Method Summary collapse

Constructor Details

#initializeGateRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GateRegistry.



22
23
24
25
# File 'lib/phronomy/runtime/gate_registry.rb', line 22

def initialize
  @mutex = Mutex.new
  @gates = {}
end

Instance Method Details

#get(name) ⇒ ConcurrencyGate

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns (or lazily creates) the gate for +name+.

Parameters:

  • name (Symbol)

Returns:



31
32
33
# File 'lib/phronomy/runtime/gate_registry.rb', line 31

def get(name)
  @mutex.synchronize { @gates[name] ||= _build(name) }
end

#reset(name) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Drops the cached gate for +name+ so the next #get rebuilds it.

Parameters:

  • name (Symbol)


39
40
41
# File 'lib/phronomy/runtime/gate_registry.rb', line 39

def reset(name)
  @mutex.synchronize { @gates.delete(name) }
end