Class: Indocker::ServerPools::DeployServerPool
- Inherits:
-
Object
- Object
- Indocker::ServerPools::DeployServerPool
- Defined in:
- lib/indocker/server_pools/deploy_server_pool.rb
Instance Method Summary collapse
- #close_sessions ⇒ Object
- #create_connection!(server) ⇒ Object
- #each(&proc) ⇒ Object
- #find_or_create_connection!(server) ⇒ Object
-
#initialize(configuration:, logger:) ⇒ DeployServerPool
constructor
A new instance of DeployServerPool.
Constructor Details
#initialize(configuration:, logger:) ⇒ DeployServerPool
Returns a new instance of DeployServerPool.
2 3 4 5 6 7 |
# File 'lib/indocker/server_pools/deploy_server_pool.rb', line 2 def initialize(configuration:, logger:) @logger = logger @configuration = configuration @connections = [] @semaphore = Mutex.new end |
Instance Method Details
#close_sessions ⇒ Object
38 39 40 |
# File 'lib/indocker/server_pools/deploy_server_pool.rb', line 38 def close_sessions @connections.each(&:close_session) end |
#create_connection!(server) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/indocker/server_pools/deploy_server_pool.rb', line 9 def create_connection!(server) connection = Indocker::ServerPools::DeployServerConnection.new( logger: @logger, configuration: @configuration, server: server, ) connection.create_session! connection end |
#each(&proc) ⇒ Object
34 35 36 |
# File 'lib/indocker/server_pools/deploy_server_pool.rb', line 34 def each(&proc) @connections.each(&proc) end |
#find_or_create_connection!(server) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/indocker/server_pools/deploy_server_pool.rb', line 19 def find_or_create_connection!(server) @semaphore.synchronize do connection = @connections.detect do |connection| connection.server.host == server.host && connection.server.port == server.port && connection.server.user == server.user end if connection.nil? connection = create_connection!(server) @connections.push(connection) end connection end end |