Sha256: 2337c65c99e46a12797fa0ffbf7e1ce4e30ac31f617cb948031b785bba65e2f0

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 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
        @config.check
        @config.reload

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

        @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

1 entries across 1 versions & 1 rubygems

Version Path
buildbox-0.2.1 lib/buildbox/server.rb