Sha256: 97f75749c938417a4fa17008239049892774c6d8b1612d39e6c9394a1635f8d0

Contents?: true

Size: 704 Bytes

Versions: 9

Compression:

Stored size: 704 Bytes

Contents

class Indocker::BuildContextPool
  def initialize(configuration:, logger:)
    @logger = logger
    @configuration = configuration

    @contexts = configuration.build_servers.map do |build_server|
      Indocker::BuildContext.new(
        logger: @logger,
        configuration: configuration,
        build_server: build_server,
      )
    end
  end

  def get
    context = nil

    loop do
      context = @contexts.detect {|c| !c.busy?}
      sleep(0.1)
      break if context
    end

    context
  end

  def each(&proc)
    @contexts.each(&proc)
  end

  def close_sessions
    @contexts.each(&:close_session)
  rescue => e
    @logger.error("error during session close: #{e.inspect}")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
indocker-0.1.8 lib/indocker/build_context_pool.rb
indocker-0.1.7 lib/indocker/build_context_pool.rb
indocker-0.1.6 lib/indocker/build_context_pool.rb
indocker-0.1.5 lib/indocker/build_context_pool.rb
indocker-0.1.4 lib/indocker/build_context_pool.rb
indocker-0.1.3 lib/indocker/build_context_pool.rb
indocker-0.1.2 lib/indocker/build_context_pool.rb
indocker-0.1.1 lib/indocker/build_context_pool.rb
indocker-0.1.0 lib/indocker/build_context_pool.rb