Sha256: b9c74811deb5b0f83c0da873867045e2dda6dbc74780cf81198e1e0f3362c259

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 Bytes

Contents

module Buildbox
  class Server
    INTERVAL = 5

    def initialize(config = Buildbox.config, logger = Buildbox.logger)
      @config = config
      @logger = logger
    end

    def start
      loop do
        worker_access_tokens.each do |access_token|
          Buildbox::Worker.new(access_token, api).work
        end

        @config.reload

        @logger.info "Sleeping for #{INTERVAL} seconds"
        sleep INTERVAL
      end
    end

    private

    def api
      @api ||= Buildbox::API.new
    end

    def worker_access_tokens
      @config.worker_access_tokens
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
buildbox-0.2 lib/buildbox/server.rb
buildbox-0.1.4 lib/buildbox/server.rb